Suppose I've got a timestamp, X.
Using PHP, how can I find the timestamp that represents noon of the day that X is from?
I guess I would need to convert X to a date, extract the day, and then convert noon from that day to a timestamp. Is there an easy way to do this in PHP?
strtotime('noon', $timestamp)
should work
<?php
$timestamp = 1346343553;
$date = getdate($timestamp);
$noon = mktime ( 12, 00, 00, $date['mon'], $date['day'], $date['year'] );
print $noon;
print date(DATE_RSS, $noon);
Of course, this goes without saying, but timezones are not factored at all. Also, strtotime()
is probably the preferred method, but getdate()
doesn't get enough love!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With