Jump to content

Mysql timestamp / php strtotime problem


Cronospulse

Recommended Posts

mysql server version = 5.1.32

 

Im trying to add 1 hour to a timestamp with strotime

The code im using to do this gives a random problem wich i cant seem to solve.

 

the following code:

//database time
echo $rows['time']."<br>";

// +1 hour
echo $time =  date("Y-m-d H:i:s", strtotime( "$rows[time] +1 hour" ))."<br><br>";

 

 

gives these values:

 

2009-04-27 16:03:47

2009-04-27 17:03:47

 

2009-04-27 16:04:53

2009-04-27 17:04:53

 

2009-04-27 16:04:59

1970-01-01 01:00:00

 

2009-04-27 16:05:06

2009-04-27 17:05:06

 

only the on date with 1970 makes no sence its exactly the same in as the other date's but it stil gives this problem.

The time is made as timestamp in mysql.

 

If some one can help me with this i would realy apreciate it im stuck on it.

Link to comment
https://forums.phpfreaks.com/topic/155843-mysql-timestamp-php-strtotime-problem/
Share on other sites

Can't reproduce it... 

1970-01-01... indiates that strtotime failed for whatever reason, but you're echoing the value before, and it seems to be fine

 

What if you try

echo $time =  date("Y-m-d H:i:s", strtotime( "$rows[time]" )+3600)."<br><br>";

 

 

It's more PHP problem than a MySQL one.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.