Localize current time in PHP

前端 未结 3 1629
情歌与酒
情歌与酒 2021-01-13 01:04

Trying to display current time with PHP (using this):

$date = date(\'m/d/Y h:i:s a\', time());                      
echo $date;

As simple

3条回答
  •  渐次进展
    2021-01-13 02:04

    If you need a more simple way than Zend_Date and IntlDateFormatter try the standard strftime function in php. Here's the stuff I did to get it up and running with the Russian language running php 5.3 on Ubuntu (Russian locale was not installed).

    To install locale

    1. cd /usr/share/locales
    2. sudo ./install-language_pack ru_RU
    3. sudo dpkg-reconfigure locales
    4. Restart Apache

    Next, use the following php snippet:

    setlocale(LC_TIME, 'ru_RU.UTF-8');
    echo strftime('%A', time());
    

    Should output today's day of the week.

提交回复
热议问题