Operating System - Linux
1758383 Members
2787 Online
108868 Solutions
New Discussion юеВ

"date" to unix time format convertion

 
Andrea Rossi
Frequent Advisor

"date" to unix time format convertion

Hi all

I need a script to convert date commmand output to unix time format.

any tested ones?
thanks
2 REPLIES 2
Stuart Browne
Honored Contributor

Re: "date" to unix time format convertion

Why not just use 'date' ?

If you want the current date in Epoc, use 'date +"%s"'.

If you have a pre-set date and want to get it as epoc, use 'date -d "Date in words" +"%s"', for example, my birthday:

date -d "march 12 1977" +"%s"

and whee! :)
One long-haired git at your service...
Gopi Sekar
Honored Contributor

Re: "date" to unix time format convertion


i am not sure of the unix time format. But i think you are asking for this.
%s seconds since `00:00:00 1970-01-01 UTC'

to get this run 'date +%s'

Hope this helps,
Gopi
Never Never Never Giveup