6
I am trying to display the exact time with PHP in the following format.
Date: YYYY-MM-DD
Time: 00:00:00:000
<?php
setlocale( LC_ALL, 'pt_BR', 'pt_BR.iso-8859-1', 'pt_BR.utf-8', 'portuguese' );
date_default_timezone_set( 'America/Sao_Paulo' );
echo strftime( '%Y-%m-%e %T', strtotime('today'));
?>
With the current code it according to my research would display this for example, 2015-01-26 00:00:00
I am using Windows7 x64 and PHP Version 5.5.8 and the page displays nothing, nor errors.
And what’s the problem?
– Jorge B.
@Jorgeb. the generated page shows nothing, no errors
– wwwjsw
In operating system you are using?
– rray
Have you seen the log? Have warnings and errors appear on the page? Or just in the log?
– Jorge B.
@rray windows 7 x64
– wwwjsw
I could not reproduce the problem http://ideone.com/eG9gmq
– Maniero
It also works well here: http://phpfiddle.org/main/code/w1f0-b7ij
– Jorge B.
the
%e
not supported by windows, strftime swap for%d
.– rray
@rray the %d is also not supported? I am trying to use it but nothing happens!
– wwwjsw
I did some tests here, it only worked with the
%d
and also removing the%T
.– rray
Ask the question the php version tbm.
– rray
@rray the date is right, I will try to solve the time, obg
– wwwjsw
Who will answer?
– Maniero
@moustache sorry I didn’t understand!
– wwwjsw
The @rray got the message.
– Maniero
If you do not need to format the date located (translated) the function
date()
it seems simpler.– rray
I always thought the function
date()
took the local time and date– wwwjsw