Those functions used to convert time format from string to binary
and vice versa.
strtotime char *
takes one string argument that represents the date and time in a number
of formats, briefly shown below.
is immune to trailing spaces, newlines and other non-printable and
printable tails. It also tries to recognize elder time formats variants
and strings created by broken implementations.
ISO-8601 notation. This form best suited for use in mixed human/automatic
parsing and comparisons. The typical date string looks like:
RFC-822 (updated by RFC-1123). This form used in the E-mail
headers, like "Data:" and other. The date in this format looks like:
Sat, 30 Sep 2000 17:24:58 +0400 (MSD)
Sat, 30 Sep 2000 17:24:58 +0400
Sat, 30 Sep 2000 17:24:58 MSD
that is but widely used, but lame,
though correctly handled by strtotime.
Sat Sep 30 17:24:58 2000
Syslog daemons form:
Mar 23 19:07:43
Unix time in numeric form. This form specifies the number of seconds passed
since the Epoch (00:00:00 UTC, January 1, 1970; see
time 3 ).
Typical form is "970257600" (signed long number).
A set of other formats that are widely used is supported too.
Thursday, 10-Jun-93 01:29:59 GMT
Thu, 10 Jan 1993 01:29:59 GMT
Wed Jun 9 01:29:59 1993 GMT
Support for other time representation formats can be added upon request.
timetostr time_t value int flags
used to convert the time value to the user-specified representation format,
specified by flags. Flags are defined in strfunc.h:
- simple numeric unix_time format.
- format defined in RFCs 822 and 1123.
- format specified in X.208.
- general representation according to ISO-8601 conventions.
Those flags are present to specify the output format. And the following ones
exist to slightly modify the output:
- construct string representing the time within the local timezone instead
of default GMT (zero timezone offset).
- user-friendly output. This flag turns on some additional features like
dashes and colons within the ISO-8601 output or timezone abbreviation within
the RFC-822 date string.
- use old RFC-822 scheme with the hard-coded GMT zone abbreviation. This
flag also disables the TFMT_LOCAL and TFMT_UF flag will be ignored. The
typical string in this format will look like
"Sat, 30 Sep 2000 21:24:58 GMT".
This time format is widely used by the HTTP browsers and CGI scripts to
exchange the "expiration" and "modified" times. This flag should be used
in conjunction with TFMT_RFC822.
Those flags can be mixed by ORing.