Perl question

Platypus

Lifer
Apr 26, 2001
31,046
321
136
I need to figure out the number of seconds left in the current day at any point.

Any suggestions?
 

Thyme

Platinum Member
Nov 30, 2000
2,330
0
0
Can you get midnight using a date function, then convert that to seconds from epoch, then do that with the current time?
 

skace

Lifer
Jan 23, 2001
14,488
7
81
I'm testing the accuracy of this, it should reach 43200 by lunch today.
 

skace

Lifer
Jan 23, 2001
14,488
7
81
Yea it appears accurate, I missed 12:00 so I did this test:

D:\Server\Scripts>todaytomorrow2.pl
today 05508
yesterday 05408
seconds left 42104
time 1618125710552161

that time field states that it was run at 12:18:16. I then did the following math:
(12*60)*60 - (18*60) - 16 = 42104

If you want to try this, add the following line:
print "time ", localtime($time_cepoch), "\n";

The first 6 characters in the time output are read: SSMMHH