1Date::Parse(3) User Contributed Perl Documentation Date::Parse(3)
2
3
4
6 Date::Parse - Parse date strings into time values
7
9 use Date::Parse;
10
11 $time = str2time($date);
12
13 ($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date);
14
16 "Date::Parse" provides two routines for parsing date strings into time
17 values.
18
19 str2time(DATE [, ZONE])
20 "str2time" parses "DATE" and returns a unix time value, or undef
21 upon failure. "ZONE", if given, specifies the timezone to assume
22 when parsing if the date string does not specify a timezome.
23
24 strptime(DATE [, ZONE])
25 "strptime" takes the same arguments as str2time but returns an
26 array of values "($ss,$mm,$hh,$day,$month,$year,$zone)". Elements
27 are only defined if they could be extracted from the date string.
28 The $zone element is the timezone offset in seconds from GMT. An
29 empty array is returned upon failure.
30
32 Date::Parse is capable of parsing dates in several languages, these are
33 English, French, German and Italian.
34
35 $lang = Date::Language->new('German');
36 $lang->str2time("25 Jun 1996 21:09:55 +0100");
37
39 Below is a sample list of dates that are known to be parsable with
40 Date::Parse
41
42 1995:01:24T09:08:17.1823213 ISO-8601
43 1995-01-24T09:08:17.1823213
44 Wed, 16 Jun 94 07:29:35 CST Comma and day name are optional
45 Thu, 13 Oct 94 10:13:13 -0700
46 Wed, 9 Nov 1994 09:50:32 -0500 (EST) Text in ()'s will be ignored.
47 21 dec 17:05 Will be parsed in the current time zone
48 21-dec 17:05
49 21/dec 17:05
50 21/dec/93 17:05
51 1999 10:02:18 "GMT"
52 16 Nov 94 22:28:20 PST
53
55 Date::Parse uses Time::Local internally, so is limited to only parsing
56 dates which result in valid values for Time::Local::timelocal
57
59 When both the month and the date are specified in the date as numbers
60 they are always parsed assuming that the month number comes before the
61 date. This is the usual format used in American dates.
62
63 The reason why it is like this and not dynamic is that it must be
64 deterministic. Several people have suggested using the current locale,
65 but this will not work as the date being parsed may not be in the for‐
66 mat of the current locale.
67
68 My plans to address this, which will be in a future release, is to
69 allow the programmer to state what order they want these values parsed
70 in.
71
73 Graham Barr <gbarr@pobox.com>
74
76 Copyright (c) 1995 Graham Barr. All rights reserved. This program is
77 free software; you can redistribute it and/or modify it under the same
78 terms as Perl itself.
79
80
81
82perl v5.8.8 2003-06-02 Date::Parse(3)