in reply to date and time difference
timelocal requires the month as a number, you're giving it a string, which is being interpreted as 0 (January). You can see this with a print gmtime($time_1)."\n";. You'd need to convert it from string to number first. Also, since your times are in GMT, you should use timegm instead.
Note that the Time::Local docs strongly recommend to use timegm_modern instead. And personally I'd strongly recommend you switch to a better module, such as Time::Piece, which has a strptime method to parse strings directly, or DateTime with DateTime::Format::Strptime. Also, your version of Perl if about 15 years old, I would strongly recommend looking into upgrading.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: date and time difference
by invisiblehand (Initiate) on Jan 08, 2020 at 15:19 UTC | |
by haukex (Archbishop) on Jan 08, 2020 at 15:23 UTC | |
by invisiblehand (Initiate) on Jan 08, 2020 at 17:55 UTC | |
by haukex (Archbishop) on Jan 08, 2020 at 19:20 UTC | |
by invisiblehand (Initiate) on Jan 08, 2020 at 23:24 UTC | |
| |
by ikegami (Patriarch) on Jan 08, 2020 at 16:51 UTC |