开发者

PHP Convert Unix time to ISO and Subtract an Hour

I'm restructuring my MySQL database, which has several columns in Unix format.

Because I already have several rows in the database in Unix format. How can I convert the Unix fields to iso, and then subtract an hour using PHP?

For example, I currently have:

<?php
 $unix_time = 1267840开发者_运维问答800;
 $conversion = date("c", $unix_time);

The above code spits out:

2010-03-05T20:00:00-06:00

My question is, how can I take it a step further and subtract an hour and just have:

2010-03-05 19:00:00


<?php
 $unix_time = 1267840800;
 $one_hour = 60 * 60;

 $conversion = date("Y-m-d h:i:s", $unix_time - $one_hour);


You could also take your timestamp and say strtotime("-1 hour", 1267840800).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜