-2

I need a quick way to convert date "Tue Jul 02 17:50:55 MDT 2024" into epoch time.

Effectively, I need the shell equivalent of date -d "Tue Jul 02 17:50:55 MDT 2024" +%s

I currently use the following in perl but it requires a lot of conversion. Hoping to find a simpler and more elegant solution.

$current_epoch = timelocal($seconds, $minute, $hour, $day_of_month, $month_num, $year)

I currently use Perl 5.8 ; I dont believe it has "Time::Piece"
I am only interested in solutions that do not require downloading another library

souser
  • 5,868
  • 5
  • 35
  • 50

1 Answers1

0

The Date::Parse module can turn datetime stamps into epoch times. In general, if you have something you need to do, search the Comprehensive Perl Archive Network for a module to handle it. Searching Stackoverflow is another good way to get answers to common questions.

brian d foy
  • 129,424
  • 31
  • 207
  • 592