Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading