php - Round datetime to last hour -


i tried not find example of im trying do.

i got datetime values in mysql database has rounded down when value on use.

example, these values:

2013-04-20 07:14:42
2013-04-20 07:19:51
2013-04-20 07:37:26
2013-04-20 07:46:28
2013-04-20 07:59:44

should rounded down to:

2013-04-20 07:00:00

and

2013-04-20 16:25:34

should be:

2013-04-20 16:00:00 etc...

php code gets date value:

$d = strtotime($row["date"]); 

so, how possible round down datetime value?

try this,

$date = "2013-04-20 16:25:34";  echo date("y-m-d h:00:00",strtotime($date)); 

codepad demo.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -