Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Check current time between range of dates and times

by Marshall (Canon)
on May 13, 2009 at 23:07 UTC ( [id://763946]=note: print w/replies, xml ) Need Help??


in reply to Check current time between range of dates and times

Epoch time is the number of seconds +or- from the epoch and is a signed integer value of some precision x. It is possible to do "time math" in seconds on epoch times. Use date/time string to create an epoch time and then add 24*60*60 seconds to it to get 24 hours from then if you want 23.5 hours then add(or subtract) 24*60*60-(30*60)..keep things in whole numbers (don't use .3 for a third of a day, use 8 hours *60 min*60 sec, etc...

So to see if your proposed date is in-between those times, convert it to epoch seconds also and do a numeric comparison.

You can use the stat func to figure out if that proposed date is Monday in your local time.

I would normally do everything in GMT or UTC as it is known today.

Of course I may have missed something here...

Update: oh, another point, when writing log files, etc. I use a format like this: 2007-10-06 1647. If leading zeroes are enforced for both date and time, then a simple alpha comparison or sort will get the right answer. To add 30 minutes to 2007-10-06 1647, I convert to epoch, add 30*60, then convert back to string (all this 24 hours, 60 minutes stuff is messy).

  • Comment on Re: Check current time between range of dates and times

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://763946]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-25 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found