获取中午PHP的时间戳


get timestamp of noon PHP

假设我有一个时间戳X.

使用PHP,我如何找到表示X来自当天中午的时间戳?

我想我需要将X转换为日期,提取日期,然后将当天的中午转换为时间戳。在PHP中有没有一种简单的方法可以做到这一点?

strtotime('noon', $timestamp)应能在上工作

<?php
$timestamp = 1346343553;
$date = getdate($timestamp);
$noon = mktime ( 12, 00, 00, $date['mon'], $date['day'], $date['year'] );
print $noon;
print date(DATE_RSS, $noon);

当然,这是不言而喻的,但时区根本没有考虑在内。此外,strtotime()可能是首选方法,但getdate()没有得到足够的爱!

strtotime支持许多这样的字符串,请查看文档。。短时

strtotime('noon', $timestamp);

作为字符串:

echo date('Y-m-d 12:00:00', $time);