therealwesfoster Posted March 10, 2009 Share Posted March 10, 2009 I'm needing to generate a total of 4 UNIX Timestamps. 1. The beginning timestamp of the current week (Sunday at 0:00:00) 2. The ending timestamp of the current week (Saturday at 23:59:59) 3. The beginning timestamp of the current day (today at 0:00:00) 4. The ending timestamp of the current day (today at 23:59:59) The current day/week of the script can be whenever, so the script should be able to function no matter what day/month/year it is Thanks! Wes Quote Link to comment Share on other sites More sharing options...
trq Posted March 10, 2009 Share Posted March 10, 2009 Where exactly are you stuck? Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted March 10, 2009 Author Share Posted March 10, 2009 I'm having trouble getting the 4 timestamps. I had to do this for the previous month's beginning/ending timestamp and I did it like this: $prev_month1 = strtotime(date("1 F Y",strtotime('-1 month'))); $prev_month2 = strtotime(date("t F Y",strtotime('-1 month'))); This snippet gets the beginning and ending timestamp for the previous month. I'm needing to do the same for the current week and current day.. but I'm stuck Wes Quote Link to comment Share on other sites More sharing options...
Mikedean Posted March 10, 2009 Share Posted March 10, 2009 <?php $weekStart = strtotime( "-1 Sunday 00:00" ); $weekEnd = strtotime( "+1 Saturday 23:59" ); $todayStart = strtotime( "00:00" ); $todayEnd = strtotime( "23:59" ); echo date( "d/m/y H:i", $weekStart ) . "<br />"; echo date( "d/m/y H:i", $weekEnd ) . "<br />"; echo date( "d/m/y H:i", $todayStart ) . "<br />"; echo date( "d/m/y H:i", $todayEnd ) . "<br />"; ?> That should do the trick. Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted March 10, 2009 Author Share Posted March 10, 2009 <?php $weekStart = strtotime( "-1 Sunday 00:00" ); $weekEnd = strtotime( "+1 Saturday 23:59" ); $todayStart = strtotime( "00:00" ); $todayEnd = strtotime( "23:59" ); echo date( "d/m/y H:i", $weekStart ) . "<br />"; echo date( "d/m/y H:i", $weekEnd ) . "<br />"; echo date( "d/m/y H:i", $todayStart ) . "<br />"; echo date( "d/m/y H:i", $todayEnd ) . "<br />"; ?> That should do the trick. You're awesome. Thanks! Wes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.