What could be error when storing the time to database?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
23 views
Perform locally:

date_default_timezone_set('Europe/Moscow'); if (isset($is_logged)) { //Add three hours to the current date $new_date = strtotime(time()) + strtotime("+3 hours"); } else { //Add thirty minutes to the current date $new_date = strtotime(time()) + strtotime("+30 minutes"); } $new_date = date('Y-m-d H:i:s', $new_date);


In DB saves $new_date, a value of type 2018-05-04 00:31:13

On a different server to the database stored the date in a wild future, for example 3148-09-03 13:10:37

What could be the problem?
by | 23 views

2 Answers

0 like 0 dislike
The problem is strtotime(time())
by
0 like 0 dislike
$tz = new \\DateTimeZone('Europe/Moscow'); if (isset($is_logged)) { //Add three hours to the current date $in the mining = new \\DateTime('+3 hours', $tz); } else { //Add thirty minutes to the current date $in the mining = new \\DateTime('+30 minutes', $tz); } var_dump($in the mining->format('Y-m-d H:i:s'));
by

Related questions

110,608 questions
257,187 answers
0 comments
40,796 users