Home > Software design >  strftime() in PHP8.1
strftime() in PHP8.1

Time:04-11

How to convert a UNIX timestamp into a formatted datestamp?

strftime is deprecated

setlocale(LC_TIME, 'da_DK');
strftime('%B', time());

I want to print the month in Danish eg. Januar

CodePudding user response:

Here is an example with IntlDateFormatter

$format = new IntlDateFormatter('da-DK', IntlDateFormatter::NONE, 
              IntlDateFormatter::NONE, NULL, NULL, "MMMM");
$monthName = datefmt_format($format, time());
echo $monthName;
  •  Tags:  
  • php
  • Related