How to print Nepali date today in PHP? [closed]

只谈情不闲聊 提交于 2019-12-01 17:40:11

Here's a little trick to obtain dates in the Nepali language:

<?php

header('Content-Type: text/plain; charset=utf-8');

$formats = array(
    IntlDateFormatter::NONE => 'IntlDateFormatter::NONE',
    IntlDateFormatter::SHORT => 'IntlDateFormatter::SHORT',
    IntlDateFormatter::MEDIUM => 'IntlDateFormatter::MEDIUM',
    IntlDateFormatter::LONG => 'IntlDateFormatter::LONG',
    IntlDateFormatter::FULL => 'IntlDateFormatter::FULL',
);
$locale = 'ne_NP';
$time_zone = 'Asia/Katmandu';

foreach($formats as $format => $label){
    echo $label . PHP_EOL;
    $fmt = new IntlDateFormatter($locale, $format, $format, $time_zone, IntlDateFormatter::GREGORIAN);
    echo $fmt->format(new DateTime) . PHP_EOL;
    echo PHP_EOL;
}
IntlDateFormatter::NONE
२०१४०२०४ ०६:१७ उत्तर मध्यान्ह

IntlDateFormatter::SHORT
२०१४-०२-०४ १८:१७

IntlDateFormatter::MEDIUM
२०१४ फेब ४ १८:१७:०९

IntlDateFormatter::LONG
२०१४ फेब्रुअरी ४ १८:१७:०९ GMT+५:४५

IntlDateFormatter::FULL
२०१४ फेब्रुअरी ४, मङ्गलबार १८:१७:०९ GMT+०५:४५
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!