Reputation: 4497
I want to display on my page the current date in this format: 22/02/2013 - 12:00 (day/month/year - hour)
I use strftime("%d/%b/%G - %R", time())
but shows nothing on the page. If I do
echo var_dump(strftime("%d/%b/%G - %R", time()))
it shows bool(false). Any idea what I'm doing wrong??
Upvotes: 3
Views: 2007
Reputation: 5768
Try this:
echo date('d/m/Y - H:s');
If you need to, you can set the timezone like this:
date_default_timezone_set('UTC');
Upvotes: 0
Reputation: 173652
Windows doesn't support %G
or %R
, you should use %Y
and %H:%M
respectively.
strftime("%d/%b/%Y - %H:%M")
Upvotes: 7
Reputation: 37915
From the strftime()
documentation:
As the output is dependent upon the underlying C library, some conversion specifiers are not supported. On Windows, supplying unknown conversion specifiers will result in 5 E_WARNING messages and return FALSE. On other operating systems you may not get any E_WARNING messages and the output may contain the conversion specifiers unconverted.
So, you are probably using unsupported format parameters.
Note: by default time()
is used for a timestamp, so you can use strftime()
with it if you require this defaul tiemstamp.
Upvotes: 7