Solved

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

Posted on 2008-10-15
7
2,246 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

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 …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

772 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