Creating unix times from datetime stamps

| | Comments (0) | TrackBacks (0)

Scenario: you want to convert "2008-08-02 12:45:01" to the unix epoch time:

use Time::Local qw/timegm/;

my $dt = "2008-08-02 12:45:01";
my @datetime  = split /\-|:|\s/, $dt;
$datetime[1]--; # months need decrementing
my $epoch_time = timegm(reverse @datetime);

0 TrackBacks

Listed below are links to blogs that reference this entry: Creating unix times from datetime stamps.

TrackBack URL for this entry: http://www.robbiebow.co.uk/mt/mt-tb.cgi/67

Leave a comment

About this Entry

This page contains a single entry by Robbie Bow published on August 3, 2008 1:06 PM.

Property Rights was the previous entry in this blog.

MySQL: Selecting non-unique records is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.21-en