Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix Timestamp - Previous Saturday 12:00

Status
Not open for further replies.

ralphiooo

Programmer
Oct 23, 2005
64
GB
Hi, is it possible to return the unix timestamp for the previous saturday at 12:00. I tried looking mktime but didn't know where to start. Appreciate if someone could help. Thanks
 
That easy :). Cheers gonna be using that function abit i think.
 
Hi one small problem if i put last sunday 00:00:00 i get the timestamp for the previous sunday (6th August) instead of the timestamp for the current sunday. Any idea of a fix. Appreciate your help once more thanks.
 
Hi, problem solved i did the following:

Code:
$last_time = strtotime('last saturday 12:00:00');
$week = 60 * 60 * 24 * 7;
	
if (time() - $week > $last_time) {
	$last_time += $week;
}
 
i suspect that is anticipated behaviour: as today is sunday i would expect "last Sunday" to be the 6th August.

by the way, you can, of course, use strtotime("midnight last sunday")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top