Posted By

yisreldov on 05/03/10


javascript date textmate bookmarklet convert

Versions (?)

Convert MySql Dates to localized dates

 / Published in: JavaScript

URL: javascript:document.body.innerHTML%20=%20document.body.innerHTML.replace(/(\d{4})-(\d{2})-(\d{2})/ig,function(match,year,month,day){return%20(new%20Date(year,month,day).toLocaleString())%20});

Will convert all of the mysql dates on the page to be localized.

  1. // javascript:document.body.innerHTML%20=%20document.body.innerHTML.replace(/(\d{4})-(\d{2})-(\d{2})/ig,function(match,year,month,day){return%20(new%20Date(year,month,day).toLocaleString())%20});
  2. document.body.innerHTML = document.body.innerHTML.replace(/(\d{4})-(\d{2})-(\d{2})/ig,function(match,year,month,day){return (new Date(year,month,day).toLocaleString()) });

Report this snippet  


RSS Icon Subscribe to comments
Posted By: yisreldov on May 3, 2010

try dates like this 2010-04-05 will be converted to something more readable, depending on your browser settings..

try clickMe

Posted By: yisreldov on May 3, 2010

The last comment didn't work, try clicking the URL above

You need to login to post a comment.