1Time::Piece::MySQL(3) User Contributed Perl DocumentationTime::Piece::MySQL(3)
2
3
4

NAME

6       Time::Piece::MySQL - Adds MySQL-specific methods to Time::Piece
7

SYNOPSIS

9         use Time::Piece::MySQL;
10
11         my $time = localtime;
12
13         print $time->mysql_datetime;
14         print $time->mysql_date;
15         print $time->mysql_time;
16
17         my $time = Time::Piece->from_mysql_datetime( $mysql_datetime );
18         my $time = Time::Piece->from_mysql_date( $mysql_date );
19         my $time = Time::Piece->from_mysql_timestamp( $mysql_timestamp );
20

DESCRIPTION

22       Using this module instead of, or in addition to, "Time::Piece" adds a
23       few MySQL-specific date-time methods to "Time::Piece" objects.
24

OBJECT METHODS

26       mysql_date / mysql_time / mysql_datetime / mysql_timestamp
27
28       Returns the date and/or time in a format suitable for use by MySQL.
29

CONSTRUCTORS

31       from_mysql_date / from_mysql_datetime / from_mysql_timestamp
32
33       Given a date, datetime, or timestamp value as returned from MySQL,
34       these constructors return a new Time::Piece object.  If the value is
35       NULL, they will retrun undef.
36
37       CAVEAT
38
39       "Time::Piece" itself only works with times in the Unix epoch, this mod‐
40       ule has the same limitation.  However, MySQL itself handles date and
41       datetime columns from '1000-01-01' to '9999-12-31'.  Feeding in times
42       outside of the Unix epoch to any of the constructors has unpredictable
43       results.
44
45       Also, MySQL doesn't validate dates (because your application should);
46       it only checks that dates are in the right format.  So, your database
47       might include dates like 2004-00-00 or 2001-02-31.  Passing invalid
48       dates to any of the constructors is a bad idea: on my system the former
49       type (with zeros) returns undef (previous version used to die) while
50       the latter returns a date in the following month.
51

AUTHOR

53       Original author: Dave Rolsky <autarch@urth.org>
54
55       Current maintainer: Marty Pauley <marty+perl@kasei.com>
56
58       (c) 2002 Dave Rolsky
59
60       (c) 2004 Marty Pauley
61
62       This program is free software; you can redistribute it and/or modify it
63       under the same terms as Perl itself.
64

SEE ALSO

66       Time::Piece
67
68
69
70perl v5.8.8                       2004-07-21             Time::Piece::MySQL(3)
Impressum