所以我有一个MYSQL时间戳,它生成的值比应该的值提前了4小时。如何从MySQL时间戳中减去4hrs并显示它?
这是我现在的密码
$mdate = date('F j, Y, g:i a',strtotime( $bm->date_added));
//$bm->dated_added returns the times stamp//
echo $mdate;
谢谢
最佳答案
当提供第二个参数时,strtotime()
将基于此日期执行计算:
$mdate = date('F j, Y, g:i a', strtotime('-4 hours', $bm->date_added));
strtotime()
可以基于这些修饰符执行多个计算。来自manual的示例:<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>
关于php - 如何在PHP中增加MySQL时间戳?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5636920/