0

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.

enter image description here

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:

enter image description here

7
  • Is date_default_timezone_set what you want?
    – Barmar
    Oct 27, 2015 at 21:49
  • I'm gonna change default time zone to Persian calendar how to do it ? Oct 27, 2015 at 21:55
  • date_default_timezone_set("name_of_persion_timezone");. I don't know the name of the timezone, I assume you do.
    – Barmar
    Oct 27, 2015 at 21:56
  • Actually I did it but it doesn't work, define("OPEN_TIME_ZONE", "Asia/Tehran"); Oct 27, 2015 at 22:03
  • Time zone is a completely separate concept from calendar system. Please edit your question to clarify. Oct 28, 2015 at 0:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.