On Commandline:
perl -e 'print scalar localtime(shift),"\n"' 1224687639;
Wed Oct 22 16:00:39 2008
In a script
---
#!/usr/bin/perl
# Date to timestamp (date2stamp.pl)
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
printf "%4d-%02d-%02d %02d:%02d:%02d\n",$year+1900,$mon+1,$mday,$hour,$min,$sec;
---
>date2stamp.pl
2008-10-26 23:43:33
To timestamp using Awk:
strftime("%Y-%m-%d %X", 1224687639)
eg
awk -F, '{OFS=","; print "\""$1"\"", strftime("%Y-%m-%d %X", substr($2,1,10))"."substr($2,11), $3, $4, $5, 0}'
Search This Blog
Code snippets and memory joggers
Sunday, October 26, 2008
Subscribe to:
Posts (Atom)
Blog Archive
About Me
- Keith
- I love to travel and meet new people, motorbikes, moving my body through dance, martial arts and yoga. I'm a lifelong learner interested in how things work, and the way people think and make their decisions. My choice of superpower would be to speak with someone and understand them completely, including their intention and for me to be able to communicate my intention to them clearly in their own language. As an Amazon Associate, I may earn from links to qualifying purchases.