shenniko Posted March 13, 2006 Share Posted March 13, 2006 Hi Guys,Need a little help..I've got an XML page that im parsing into my MySQL Database, but the Date/Time is in Unix Date/Time...How Can i Convert the Unix Date Time, and insert it into my MySQL Database???Ive tried the below code, but its not working..[code]$sGMTMySqlString = gmdate("Y-m-d H:i:s", $availTime);$tParsedTime = strtotime($sGMTMySqlString . " GMT");$Query = "INSERT INTO tblresources (MyPlanet,MyName,MyType,MyCD,MyCR,MyDR,MyER,MyFL,MyHR,MyMA,MyOQ,MyPE,MySR,MyUT,MyAvail) VALUES (\"$MyPlanet\", \"$MyName\", \"$MyType\", \"$MyCD\", $MyCR, $MyDR, $MyER, $MyFL, $MyHR, $MyMA, $MyOQ, $MyPE,$MySR,$MyUT, $tParsedTime)";[/code]And my MyAvail field in my MySQL DB is in DateTime format...Any Ideas?thanks in advanceShenn Quote Link to comment Share on other sites More sharing options...
fenway Posted March 13, 2006 Share Posted March 13, 2006 You can use the FROM_UNIXTIME() MySQL function to convert it to a valid MySQL datetime value. BTW, you have a strange HTML entity in your query string, and you might as well use single quotes for the VALUES to avoid have to do all that escaping.Hope that helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.