1Time::gmtime(3pm) Perl Programmers Reference Guide Time::gmtime(3pm)
2
3
4
6 Time::gmtime - by-name interface to Perl's built-in gmtime() function
7
9 use Time::gmtime;
10 $gm = gmtime();
11 printf "The day in Greenwich is %s\n",
12 (qw(Sun Mon Tue Wed Thu Fri Sat Sun))[ $gm->wday() ];
13
14 use Time::gmtime qw(:FIELDS);
15 gmtime();
16 printf "The day in Greenwich is %s\n",
17 (qw(Sun Mon Tue Wed Thu Fri Sat Sun))[ $tm_wday ];
18
19 $now = gmctime();
20
21 use Time::gmtime;
22 use File::stat;
23 $date_string = gmctime(stat($file)->mtime);
24
26 This module's default exports override the core gmtime() function,
27 replacing it with a version that returns "Time::tm" objects. This
28 object has methods that return the similarly named structure field name
29 from the C's tm structure from time.h; namely sec, min, hour, mday,
30 mon, year, wday, yday, and isdst.
31
32 You may also import all the structure fields directly into your
33 namespace as regular variables using the :FIELDS import tag. (Note
34 that this still overrides your core functions.) Access these fields as
35 variables named with a preceding "tm_" in front their method names.
36 Thus, "$tm_obj->mday()" corresponds to $tm_mday if you import the
37 fields.
38
39 The gmctime() function provides a way of getting at the scalar sense of
40 the original CORE::gmtime() function.
41
42 To access this functionality without the core overrides, pass the "use"
43 an empty import list, and then access function functions with their
44 full qualified names. On the other hand, the built-ins are still
45 available via the "CORE::" pseudo-package.
46
48 While this class is currently implemented using the Class::Struct
49 module to build a struct-like class, you shouldn't rely upon this.
50
52 Tom Christiansen
53
54
55
56perl v5.32.1 2021-05-31 Time::gmtime(3pm)