phpretard Posted June 4, 2009 Share Posted June 4, 2009 I would like to display the current month's 1st and last day. It has to be simple I just cant figure it out based on php.net's site $First=date('Y-m-d h:i:s'); $Last=date('Y-m-d h:i:s'); echo $First should be "2009-6-1 12:01" echo $Last should be "2009-6-30 11:59" Thank you for looking. Link to comment https://forums.phpfreaks.com/topic/160904-solved-simple-date-question/ Share on other sites More sharing options...
gevans Posted June 4, 2009 Share Posted June 4, 2009 something like this; echo $first_day = date("Y-m-d", strtotime("1 ". date("F Y"))); echo '<br />'; echo $last_day = date("Y-m-d", strtotime(date("t F Y"))); Link to comment https://forums.phpfreaks.com/topic/160904-solved-simple-date-question/#findComment-849146 Share on other sites More sharing options...
phpretard Posted June 4, 2009 Author Share Posted June 4, 2009 Thank you very much. echo $first_day = date("Y-m-d h:i:s", strtotime("1 ". date("F Y"))); echo '<br />'; echo $last_day = date("Y-m-d h:i:s", strtotime(date("t F Y "))); above outputs: 2009-06-01 12:00:00 2009-06-30 12:00:00 I dont quite understand: "strtotime(date("t F Y ")));" Where can I adjust to output?: 2009-06-01 12:00:00 2009-06-30 11:59:59 Thanks again Link to comment https://forums.phpfreaks.com/topic/160904-solved-simple-date-question/#findComment-849160 Share on other sites More sharing options...
gevans Posted June 4, 2009 Share Posted June 4, 2009 <?php echo date("Y-m-d 12:00:00", strtotime("1 ". date("F Y"))); echo '<br />'; echo date("Y-m-d 11:59:59", strtotime(date("t F Y"))); ?> I've just put it in manually, as the start and end time of a day aren't changing anytime soon Link to comment https://forums.phpfreaks.com/topic/160904-solved-simple-date-question/#findComment-849161 Share on other sites More sharing options...
phpretard Posted June 4, 2009 Author Share Posted June 4, 2009 Nice... Link to comment https://forums.phpfreaks.com/topic/160904-solved-simple-date-question/#findComment-849164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.