GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Time::Piece::MySQL(3) User Contributed Perl Documentation Time::Piece::MySQL(3)

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

  use Time::Piece::MySQL;

  my $time = localtime;

  print $time->mysql_datetime;
  print $time->mysql_date;
  print $time->mysql_time;

  my $time = Time::Piece->from_mysql_datetime( $mysql_datetime );
  my $time = Time::Piece->from_mysql_date( $mysql_date );
  my $time = Time::Piece->from_mysql_timestamp( $mysql_timestamp );

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

Returns the date and/or time in a format suitable for use by MySQL.

Given a date, datetime, or timestamp value as returned from MySQL, these constructors return a new Time::Piece object. If the value is NULL, they will retrun undef.

"Time::Piece" itself only works with times in the Unix epoch, this module has the same limitation. However, MySQL itself handles date and datetime columns from '1000-01-01' to '9999-12-31'. Feeding in times outside of the Unix epoch to any of the constructors has unpredictable results.

Also, MySQL doesn't validate dates (because your application should); it only checks that dates are in the right format. So, your database might include dates like 2004-00-00 or 2001-02-31. Passing invalid dates to any of the constructors is a bad idea: on my system the former type (with zeros) returns undef (previous version used to die) while the latter returns a date in the following month.

Original author: Dave Rolsky <autarch@urth.org>

Current maintainer: Marty Pauley <marty+perl@kasei.com>

(c) 2002 Dave Rolsky

(c) 2004 Marty Pauley

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Time::Piece
2008-06-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.