Skip to content

Instantly share code, notes, and snippets.

@jose-neta
Created February 27, 2013 14:06
Show Gist options
  • Save jose-neta/5048130 to your computer and use it in GitHub Desktop.
Save jose-neta/5048130 to your computer and use it in GitHub Desktop.
How to mangle dates to please MySQL
#! /usr/bin/env perl
use strict;
use warnings;
# NOTE http://xkcd.com/1179/
my $d = '02-05-2012 15:50:23'; # => 2012-05-02 15:50:23
my ( $date, $time ) = split( ' ', $d );
print join( ' ', ( join( '-', reverse( split( '-', $date ) ) ), $time) );
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment