Jump to content

Shell Script Date YYYYMMDD Format

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Tor

Tor

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 486 posts
I just spent 30 minutes finding this information so I thought I would post it. If you need the date and time in a shell script with YYYYMMDD format and HHMM format here is the script commands:

TIME=$(date +%k%M)
DAY=`/bin/date +%Y%m%d`
Output:
1305
20080818


#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
The man-page of date has all the specifiers listed.

#3
Tor

Tor

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 486 posts
It does, so you can use the man page and change the above script as you need.