- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to convert date
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 12:53 AM
тАО05-09-2003 12:53 AM
Do anyone know how to convert the date format from MMYYDD to the seconds from 1970? And how to revert it back to MMYYDD?
Thank you so much!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 12:58 AM
тАО05-09-2003 12:58 AM
Re: How to convert date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 12:59 AM
тАО05-09-2003 12:59 AM
Re: How to convert date
Thanks Clay!
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 01:05 AM
тАО05-09-2003 01:05 AM
Re: How to convert date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 01:13 AM
тАО05-09-2003 01:13 AM
Re: How to convert date
Might be useful
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x9b9f663ce855d511abcd0090277a778c,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 01:25 AM
тАО05-09-2003 01:25 AM
Re: How to convert date
Also this
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x26e3ff77de2bd611abd50090277a778c,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 01:46 AM
тАО05-09-2003 01:46 AM
Re: How to convert date
tricky to do in a few lines. Perl can return the seconds:
# perl -e 'print time,"\n"'
1052472882
which can be converted to something more humane with a few lines of shell code, e
.g.:
# NUM_SECS=1052472882
# echo "0d${NUM_SECS}=Y" | adb
2003 May 9 09:34:42
but notice that the TZ setting influences the result of the above, e.g. on my system:
# TZ=MET-1METDST
# NUM_SECS=0
# echo "0d${NUM_SECS}=Y" | adb
1970 Jan 1 01:00:00
where you might have expected 00:00:00 hours!
Hope it helps.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 01:58 AM
тАО05-09-2003 01:58 AM
Re: How to convert date
But I couldn't run the script(date2epoch.pl) successfully. The error is like this:
syntax error in file ./date2epoch.pl at line 3, next 2 tokens "use Time"
Illegal modulus of constant zero in file ./date2epoch.pl at line 4, next 2 token
s "months="
Illegal expression (MODULO) as lvalue in file ./date2epoch.pl at line 4, next 2
tokens "qw("
syntax error in file ./date2epoch.pl at line 4, next 2 tokens "qw("
Illegal modulus of constant zero in file ./date2epoch.pl at line 5, next 2 token
s "days="
Illegal expression (MODULO) as lvalue in file ./date2epoch.pl at line 5, next 2
tokens "qw("
syntax error in file ./date2epoch.pl at line 5, next 2 tokens "qw("
Execution of ./date2epoch.pl aborted due to compilation errors.
Thanks John K.
perl -e 'print time,"\n"' is my wanted. But, how about when I want to specified a date as MMDDYY to be seconds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 02:11 AM
тАО05-09-2003 02:11 AM
SolutionHere's a couple of "one-liners":
# perl -e 'use Time::Local;$ARGV[0]=~/(..)(..)(..)/;$2 < 70 ? $year=$2+100 : $year=$2;print timegm(0,0,0,$3,$1-1,$year),"\n"' 050309
1052438400
# perl -e '($mday,$mon,$year)=(gmtime(shift))[3,4,5];$year-=100 if ($year>=100);printf("%02d%02d%02d\n",$mon+1,$year,$mday)' 1052438400
050309
You need to use a more up-to-date version of perl, that's why you're getting the errors.
rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2003 02:12 AM
тАО05-09-2003 02:12 AM
Re: How to convert date
Think of the devil and here he is.