Solved

how to convert date from one format to epoch in bash ?

Posted on 2008-10-15
7
2,242 Views
Last Modified: 2013-12-26
what is the way to convert "Wed Oct 15 04:58:06 2008" to epoch using bash ?
0
Comment
Question by:beer9
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 22720715
the requirement is not clear can you elaborate?
0
 
LVL 8

Expert Comment

by:nognew
ID: 22721605
It is possible if you have a GNU date installed.
Ex:
date +%s --date="Wed Oct 15 04:58:06 2008"

gives you:

1224043086

Open in new window

0
 

Author Comment

by:beer9
ID: 22722550
I am using BSD, i do not have Gnu date. is there way to accomplish above example in BSD ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:nognew
ID: 22722688
you can install GNU date. Is that an option for you?
Also you can do it with Perl. Do you want Perl script ?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22725311
If you want to do it in pure bash, it's going to be a pretty tedious script.  GNU date really is your best/easiest option.
0
 
LVL 48

Accepted Solution

by:
Tintin earned 125 total points
ID: 22725346
Actually, you may be able to use the BSD date command like:


date -j -f date -j -f "%a %b %d %T %Y" "Wed Oct 15 04:58:06 2008" +"%s"
0
 

Author Closing Comment

by:beer9
ID: 31506264
Excellent!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now