natasha_sharma Posted January 3, 2016 Share Posted January 3, 2016 Friends, I asked my freelancer to convert the date in my raw data (Bulletin Date : 18/09/2015) to be as 18-sep-2015 But later i found out that the application which will read this DB (using ODBC) requires date to be a TIMESTAMP format. $text = file_get_contents($name); $date = getbetween($text, "Bulletin Date : ", "\n"); $date = substr($date, 0, 11); $date = explode("/", $date); $date = $date[0] . "-" . $date[1] . "-" . $date[2]; $date = date_create($date); $date = date_format($date, "d-M-Y"); Now, I do not have the freelancer working anymore and I am so Stuck. I have now two questions: 1) What changes to be done in above code so the date becomes in TIMESTAMP format? 2) Also, what datatype should i setup for DATE field using PHPMYADMIN? Please any help? Thanks Natasha Quote Link to comment Share on other sites More sharing options...
benanamen Posted January 3, 2016 Share Posted January 3, 2016 (edited) The column type should be 'date' and the date should be in the format YYY-MM-DD, ie. 2015-12-25. You can use Mysql's STR_TO_DATE to update the data in your DB and then change the column type. Edited January 3, 2016 by benanamen Quote Link to comment Share on other sites More sharing options...
natasha_sharma Posted January 3, 2016 Author Share Posted January 3, 2016 1) why yyyy-mm-dd? Is it a timestamp format? then where is TIme? 2) Also why DATE datatype in MysqlDB? There is already a TIMESTAMP type datatype in MYSQL is that not the right datatype? Sure u read the question correctly? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted January 3, 2016 Share Posted January 3, 2016 1) why yyyy-mm-dd? Is it a timestamp format? then where is TIme? Is it really so hard to google for the MySQL manual? Date and time literals 2) Also why DATE datatype in MysqlDB? There is already a TIMESTAMP type datatype in MYSQL is that not the right datatype? You specifically asked for a date type, and that's what DATE is for. Using a timestamp when there's no time doesn't make sense. 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.