[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Need to convert standard time to epoch in bash
- Subject: [ale] Need to convert standard time to epoch in bash
- From: fletch at phydeaux.org (Mike Fletcher)
- Date: Tue, 17 Apr 2007 12:40:33 -0400
- In-reply-to: <[email protected]>
- References: <[email protected]>
Ned Williams wrote:
> Greeting ale friends,
>
> I need to add function to a script with*out* using perl to convert
> standard time to UNIX Epoch time...anyone have code to do this?
>
> I can find plenty of examples as well as the date command intself to
> convert epoch to time but not the other way around
Define "standard time"? ISO8601? HTTP format? As produced by date(1)?
That aside, it's not going to be trivial to do without a more general
purpose language. I'm sure one could whip up something purely in bash
to do it, but you're going to be reimplementing wheels which are already
available in Perl (or Ruby, or Python, or whatever other language with
date manipulation routines available). Unless you've got really good
reasons (this is for your 16M keychain drive distribution that doesn't
have Perl installed) it's just inviting headaches to not use DateTime
(or Date::Parse, or even Time::Local (which ships with perl) and a
couple regexen).