How to store date in database based on different calendars?

萝らか妹 提交于 2019-12-11 13:14:37

问题


I'm gonna change current local date to new local date and time. As something I know, This is the code: For example:

date_default_timezone_set("Asia/Calcutta");
date_default_timezone_get(); // Show current date & time

or using third party to change date, something like this:

    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;

These ways only can set time & date based on local time zone & date, but it won't change current date in fact based on another calendars. More information

For example:

Today is in Gregorian Calendar: 2015 - Oct - 27

Today is in Hebrew Calendar: 5776 - 08 - 14

Today is in Hijri Calendar: 1437 - 01 - 14

Today is in Persian Calendar: 1394 - 08 - 06

I tried most of ways to change current date to another date, but actually all the ways I tried just will convert Gregorian calendar to another calendars but it can not physically change local date.

I mean if we will store date into database, it will store based on Gregorian Calendar but it will show it based on another calendars. (( Depends on settings how you set date default or third party ))

Q: Is there any way to change physically local date in server using php or there's no anyway ?

Thanks in advance for any comment on this issue.

some of the ways I tried are:

Hijri, jDateTime, Jewish, php.ini, timezone, default timezone

来源:https://stackoverflow.com/questions/33380573/how-to-store-date-in-database-based-on-different-calendars

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