Answer the question
In order to leave comments, you need to log in
Php new DateTime() changes the time from 10 o'clock to 22 o'clock. Why?
Problem: php itself changes 10 hours to 22 hours.
Execution order:
php is executed. At the very beginning, I set the time to international in it:
Then I write the current date and time to the database like this:date_default_timezone_set('UTC');
$tmptime = new DateTime();
$tmpstr = "INSERT INTO ... email_send='".$tmptime->format(DATETIMEFORMAT)."'";
$email_send = $data['email_send'];
$alerts->add('$email_send='.$email_send,'info',$email_send);
$datetime1 = DateTime::createFromFormat(DATETIMEFORMAT, $email_send); //тут пробовал по разному - результат один и тот же.
$datetime2 = new DateTime();
$alerts->add('$datetime1='.$datetime1->format(DATETIMEFORMAT),'info',$datetime1);
$alerts->add('$datetime2='.$datetime2->format(DATETIMEFORMAT),'info',$datetime2);
$interval = $datetime1->diff($datetime2);
$alerts->add('$interval='.$interval->format('%y-%m-%d %h:%i:%s'));
$email_send=2015-01-10 10:44:47 = 2015-01-10 10:44:47 // string received from the database
$datetime1=2015-01-10 10:44:47 = DateTime Object ( [date] => 2015-01-10 10:44:47 [timezone_type] => 3 [timezone] => UTC )
$datetime2=2015-01-10 10:54:39 = DateTime Object ( [date] => 2015-01 -10 22:54:39 [timezone_type] => 3 [timezone] => UTC )
$interval=0-0-0 12:9:52
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question