Does the PHP date() function format the time to the current locale time

I am trying to use the date() function as an alternative to the now deprecated strftime() function, and I need to know whether the date() function formats the time like the strftime() function according to the locale time.

strftime()

As said by php.net in the strftime() manual:

strftime — Format a local time/date according to locale settings

But in the date() function manual date() it only says:

date — Format a Unix timestamp

So does it format the Unix timestamp to the locale settings?

>Solution :

Welcome on StackOverflow.

Date formats a Unix timestamp.
Unix timestamp means seconds from epoch.
Epoch is the Thursday, 01 January 1970 00:00:01.000
Where I live (CET), this is the Thursday, 01 January 1970 00:00:01.000 +01:00, so it depends on your locale

echo date(DATE_RFC2822,0); //return Thu, 01 Jan 1970 00:00:00 +0000

But if you set your locale, result is different:

date_default_timezone_set('CET');
echo date(DATE_RFC2822,0); //return Thu, 01 Jan 1970 00:00:00 +0100

About the languages, this method does not use "locales". All outputs are in English.

Leave a Reply