idlastro / Astronomical Utilities: GET_DATE

[Source code]

NAME
GET_DATE
PURPOSE
Return the (current) UTC date in CCYY-MM-DD format for FITS headers
EXPLANATION
This is the format required by the DATE and DATE-OBS keywords in a 
FITS header.  
CALLING SEQUENCE
GET_DATE, FITS_date, [ in_date, /OLD, /TIMETAG ]
OPTIONAL INPUTS
in_date - string (scalar or vector) containing dates in IDL
     systime() format (e.g. 'Tue Sep 25 14:56:14 2001')
OUTPUTS
FITS_date = A scalar character string giving the current date.    Actual
        appearance of dte depends on which keywords are supplied.
No Keywords supplied - dte is a 10 character string with the format
        CCYY-MM-DD where  represents a calendar year,  the
        ordinal number of a calendar month within the calendar year, 
        and 
the ordinal number of a day within the calendar month. /TIMETAG set - dte is a 19 character string with the format CCYY-MM-DDThh:mm:ss where represents the hour in the day, the minutes, the seconds, and the literal 'T' the ISO 8601 time designator /OLD set - dte is an 8 character string in DD/MM/YY format
INPUT KEYWORDS
/TIMETAG - Specify the time to the nearest second in the DATE format
/OLD - Return the DATE format formerly (pre-1997) recommended for FITS
        Note that this format is now deprecated because it uses only
        a 2 digit representation of the year. 
EXAMPLE
Add the current date to the DATE keyword in a FITS header,h
IDL> GET_DATE,dte
IDL> sxaddpar, h, 'DATE', dte, 'Date header was created'
NOTES
(1) A discussion of the DATExxx syntax in FITS headers can be found in
http://www.cv.nrao.edu/fits/documents/standards/year2000.txt
(2) Those who wish to use need further flexibility in their date 
formats (e.g. to use TAI time) should look at Bill Thompson's time
routines in http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/time
PROCEDURES USED
DAYCNV - Convert Julian date to Gregorian calendar date
REVISION HISTORY
Written      W. Landsman          March 1991
Major rewrite to write new DATExxx syntax  W. Landsman  August 1997
Converted to IDL V5.0   W. Landsman   September 1997
Work after year 2000 even with /OLD keyword W. Landsman January 2000
Don't need to worry about TIME_DIFF since V5.4 W. Landsman July 2001
Assume since V5.4, remove LOCAL_DIFF keyword  W. Landsman April 2006