使用PHP从时间戳减去6小时

Jef*_*mas 5 php mysql

我有这段代码来显示数据库中的日期和时间.如何修改它以从时间戳减去6小时.

date('m-d g:Ga', strtotime($row['time_stamp']))
Run Code Online (Sandbox Code Playgroud)

ick*_*fay 15

UNIX时间戳是Epoch以来的秒数.只需减去六小时内的秒数:

date('m-d g:Ga', strtotime($row['time_stamp'])-21600)
Run Code Online (Sandbox Code Playgroud)

您也可以strtotime再次使用:

date('m-d g:Ga', strtotime('-6 hours', strtotime($row['time_stamp'])))
Run Code Online (Sandbox Code Playgroud)