Jump to content

Get the timestamp of midnight of the current day


JasonO

Recommended Posts

Hi everyone,

 

How would I go about getting the timestamp of the current day, rounded to the most recent time of 00:00?

For example, If I used 10/02/2010 at 14:43:32 it would give me a timestamp for that by default (as that is the current time of posting this). However, how would I get it to get the timestamp for 10/02/2010 00:00 ?

 

Is there a way to easily round the earliest 00:00 time? I don't want it to round ahead as I can't time travel.

 

Thanks.

Link to comment
Share on other sites

I thought the timestamp is the number of seconds since 1st Janurary 1970?

 

I would like to store the date with the time being 00:00, otherwise I'll have the problem when the cron job runs the script just after midnight (runs every day at 00:05), it won't see the time as being 'today'.

 

If the number of seconds at midnight is 1000 for example, at 1 minute past midnight it would be 1060. In 10 minutes it would be 1600. If I wanted to see if anything of that day was due, it wouldn't work correctly as 1000 is less than 1060 for example. Damn, I'm finding this really hard to explain. Heh.

 

Is there a better way of doing it then? I just wanted to go by the current concept of that if the checking script run by the cron has a current time thats after the one in the database, it would mean that the database row needs updating. If the time in the database is at, say 2PM, the cron job wont pick that up until the next cron.

 

Sorry I'm not very good at explaining it :|

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.