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.
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?
CodePudding user response:
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.
CodePudding user response:
You already linked the perfect source for information on that matter.
The format information on the date()
docs page points to the DateTimeeInterface::format
page (https://www.php.net/manual/en/datetime.format.php) that states:
This method does not use locales. All output is in English.