HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- UNIX date formatting feature - printf style
Operating System - HP-UX
1828621
Members
1325
Online
109983
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
09-18-2006 12:54 AM
09-18-2006 12:54 AM
Hi,
I’m attempting to use the ‘date’ command with the C-style formatting to format my variables:
Prefix=20
Year=06
Month=MM
Day=DD
I’d like to format it using the C language style format i.e.
printf("%02d%02d%02d%02d" $prefix $year $month $day)
and also in the following format:
printf("%02d%02d-%02d-%02d" $prefix $year $month $day)
I’ve tried using the “- - date “ option:
mz[tmp]$ date --date="20060918"
Mon Sep 18 00:00:00 SGT 2006
mz[tmp]$ date --date="2006-09-18"
Mon Sep 18 00:00:00 SGT 2006
Could anyone show me how I can set the date formatting (specifying the number of digit formats), using ‘date’ utility, or even any other utilities?
Thanks
Danny
I’m attempting to use the ‘date’ command with the C-style formatting to format my variables:
Prefix=20
Year=06
Month=MM
Day=DD
I’d like to format it using the C language style format i.e.
printf("%02d%02d%02d%02d" $prefix $year $month $day)
and also in the following format:
printf("%02d%02d-%02d-%02d" $prefix $year $month $day)
I’ve tried using the “- - date “ option:
mz[tmp]$ date --date="20060918"
Mon Sep 18 00:00:00 SGT 2006
mz[tmp]$ date --date="2006-09-18"
Mon Sep 18 00:00:00 SGT 2006
Could anyone show me how I can set the date formatting (specifying the number of digit formats), using ‘date’ utility, or even any other utilities?
Thanks
Danny
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 01:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 01:06 AM
09-18-2006 01:06 AM
Re: UNIX date formatting feature - printf style
Danny,
can you please clarify:
Are you trying to update the date display to a certain format ( Display Formatted Date Using Local Language Conversion )
or
are you trying to display the date in a certain format ( date "+DATE: %m/%d/%y%nTIME: %H:%M:%S" )
See man for both
can you please clarify:
Are you trying to update the date display to a certain format ( Display Formatted Date Using Local Language Conversion )
or
are you trying to display the date in a certain format ( date "+DATE: %m/%d/%y%nTIME: %H:%M:%S" )
See man for both
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 03:17 AM
09-18-2006 03:17 AM
Re: UNIX date formatting feature - printf style
Hi,
it seems to me, that you are using GNU-date. Using the option '--date' does not have any influence of the output style, it just changes the input date+time. Use the well-known %-modifier (see 'man stftime') to change the output format:
date --date="" '+%Y%m%d'
mfG Peter
it seems to me, that you are using GNU-date. Using the option '--date' does not have any influence of the output style, it just changes the input date+time. Use the well-known %-modifier (see 'man stftime') to change the output format:
date --date="
mfG Peter
The Universe is a pretty big place,
it's bigger than anything anyone has ever dreamed of before.
So if it's just us, seems like an awful waste of space, right?
Jodie Foster in "Contact"
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP