@gil_davisAug 08.2007 — #What you have posted appears to be a Unix timestamp rather than a MySQL timestamp. Unix timestamps are the # of seconds since 1/1/1970. MySQL timestamps are yyyymmddhhmmss.
JavaScript uses milliseconds since 1/1/1970. So if you actually have a Unix timestamp, just multiply it by 1000 and convert it using new Date(). <i> </i>var unixTime = 1164279208; var jsTime = unixTime * 10000; var theTime = new Date(jsTime); alert(theTime); // you will get "Thu Nov 23 05:53:28 EST 2006" var theMonth = theTime.getMonth() + 1; theMonth = (theMonth < 10) ? "0" + theMonth : theMonth; var theDay = theTime.getDay(); theDay = (theDay < 10) ? "0" + theDay : theDay; var theYear = theTime.getFullYear(); alert(theMonth + "-" + theDay + "-" + theYear); // will be "11-23-2006"
If you actually have a MySQL timestamp: <i> </i>var MySQLTime = 20061123000000; var theMonth = Math.floor((MySQLTime - theYear * 10000000000) / 1000000); var theDay = theMonth % 100; theMonth = Math.floor(theMonth / 100); theMonth = (theMonth < 10) ? "0" + theMonth : theMonth; theDay = (theDay < 10) ? "0" + theDay : theDay; alert(theMonth + "-" + theDay + "-" + theYear); // will be "11-23-2006"
@kreelinauthorAug 08.2007 — #Thank you, this is wht i did [CODE]function dateTransform (smartlinkdate) { var ladate = new Date(smartlinkdate*1000); var lejour = ladate.getDay(); var lemois = ladate.getMonth(); var lannee = ladate.getFullYear(); return (lejour + "-" + lemois + "-" + lannee); }[/CODE]