trollolodn

#javascript: convert date php to date js

May 10th, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Date.createFromMysql = function(mysql_string)
  2. {
  3.    if(typeof mysql_string === 'string')
  4.    {
  5.       var t = mysql_string.split(/[- :]/);
  6.  
  7.       //when t[3], t[4] and t[5] are missing they defaults to zero
  8.       return new Date(t[0], t[1] - 1, t[2], t[3] || 0, t[4] || 0, t[5] || 0);          
  9.    }
  10.  
  11.    return null;  
  12. }
Advertisement
Add Comment
Please, Sign In to add comment