本文介绍了如何在PHP日期时间中添加秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在日期时间添加秒。 ex。我有日期时间2009-01-14 06:38:18 我需要在该日期中添加-750秒,并希望在日期时间中得到结果
How can I add second(s) in a date time. ex. I have date time 2009-01-14 06:38:18 I need to add -750 seconds in that date and want result in datetime
推荐答案您需要将该日期转换为 unix时间戳,其中此类操作很简单:
You need to convert that date to a unix timestamp, where such operations are trivial:
$unix_timestamp = strtotime('2009-01-14 06:38:18'); $new_string = date('Y-m-d H:i:s', $unix_timestamp - 750);更多推荐
如何在PHP日期时间中添加秒
发布评论