Hey guys, I want to find the timestamp at the start of a particular date to the end of that day. i.e. 00:00:00am-11:59:59pm How would I do this. For example if I had the date 02:02:2009 (2nd february 2009) how would I get the starting and ending timestamp. Thanks
// Start of today's server time echo strtotime(date("Y-m-d 00:00:01")); // End of today's server time echo strtotime(date("Y-m-d 23:59:59")); PHP:
I'm trying to get the timestamp of a date 10 days ago. I got this so far and it works if the date is less than 10 (it will decrease the month by one) but it doesn't work for years - i've just noticed this because of the new year. $daydate = date("d"); $monthdate = date("m"); $yeardate = date("Y"); $day_10 = ($daydate - 10); $daydate10 = $yeardate . "-" . $monthdate . "-" . $day_10; $daydate10_start = strtotime(date("$daydate10 00:00:00")); $daydate10_end = strtotime(date("$daydate10 23:59:59")); PHP: Anyone know of any functions to do the same thing as this but works for any date?
You can get a date 10 days ago as such, if that's what you mean: $ten_days_ago = time()-(86400*10); $format = date("M d Y h:i:s", $ten_days_ago); Code (markup):
Thanks for your reply cozmic but if the current time is 5:00 on the 3rd Jan 2010 then it'll give me the timestamp of 5:00 on the 24th December but i want the time 0:00 on the 24th december. Also, I want date to timestamp, not timestamp to date. Anyway thanks for your help.
$days = -10; // Ten days ago $timestamp = strtotime( date( "Y-m-d 00:00:01", time() + ( 86400 * $days ) ) ) ; PHP: Try that