Jump to content

[SOLVED] Simple Date question


phpretard

Recommended Posts

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
Share on other sites

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
Share on other sites

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.