Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2008-10-15
7
2,251 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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