Skip to content

Instantly share code, notes, and snippets.

@stlsmiths
Created February 1, 2012 16:08
Show Gist options
  • Save stlsmiths/1717748 to your computer and use it in GitHub Desktop.
Save stlsmiths/1717748 to your computer and use it in GitHub Desktop.
//
// Custom Parser for SQL formatted date strings ...
//
// Following taken directly from Satyam's YUIBlog article:
// http://yuiblog.com/blog/2008/10/15/datatable-260-part-one/
//
// This is used in the formatter below, to first convert the data to a JS Date, then format it !!!
var parseSQLDate = function (o) {
var parts = o.split(' ');
datePart = parts[0].split('-');
if (parts.length > 1) {
var timePart = parts[1].split(':');
return new Date(datePart[0],datePart[1]-1,datePart[2],timePart[0],timePart[1],timePart[2]);
} else {
return new Date(datePart[0],datePart[1]-1,datePart[2]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment