• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2263
  • Last Modified:

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

what is the way to convert "Wed Oct 15 04:58:06 2008" to epoch using bash ?
0
beer9
Asked:
beer9
  • 2
  • 2
  • 2
  • +1
1 Solution
 
omarfaridCommented:
the requirement is not clear can you elaborate?
0
 
nognewCommented:
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
 
beer9Author Commented:
I am using BSD, i do not have Gnu date. is there way to accomplish above example in BSD ?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
nognewCommented:
you can install GNU date. Is that an option for you?
Also you can do it with Perl. Do you want Perl script ?
0
 
TintinCommented:
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
 
TintinCommented:
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
 
beer9Author Commented:
Excellent!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now