How to change current server calendar date to another calendar date in php?

筅森魡賤 提交于 2019-12-12 03:24:48

问题


I'm gonna change current date to new date in php, In following code current date shows on page in Persian calendar, but it doesn't change real Gregorian date.

For example: If we stored date: 2015-01-03 in database, this code convert this date to new date in Persian Calendar and it will show it on page.

public static function localDate($date = "")
{
    $local = "";
switch (strlen($date))
    {
   default: // Ymd
      {
      if (( $date < '19700101'))
      {
    $local = $date;
    break;
      }
      else
      {
        header('Content-Type: text/html; charset=UTF-8');
        require_once dirname(__FILE__) . '/jdatetime.class.php';
        $local = jDateTime::date("l j F Y", strtotime($date), true, true, 'Asia/Tehran');
        break;
      }
    }
    break;
}
return $local;

}

Here is jdatetime.class.php

Question: How can I change current date to new date in server? I'm gonna store date based on Persian Calendar How to changed server date from Gregorian to Persian calendar?

Here's sample of my problem:

来源:https://stackoverflow.com/questions/33379015/how-to-change-current-server-calendar-date-to-another-calendar-date-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!