dflow Posted February 21, 2011 Share Posted February 21, 2011 iwant this format dd-mm-yyyy i have a DATETIME var set to DATETIME type in the DB <?php echo date_format($row['DATETIME'],'%m-%d-%Y') ?> ERROR: Warning: date_format() expects parameter 1 to be DateTime, string given on line 510 Quote Link to comment https://forums.phpfreaks.com/topic/228426-date_format-help/ Share on other sites More sharing options...
kenrbnsn Posted February 21, 2011 Share Posted February 21, 2011 The DateTime format that the error message mentions is not the same as the DATETIME column type in MySQL. The manual page for the date_format function points you to the manual page for DateTime::format which tells you what it's looking for: <?php $date = date_create($row['DATETIME']); echo date_format($date,'m-d-Y'); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/228426-date_format-help/#findComment-1177843 Share on other sites More sharing options...
denno020 Posted February 22, 2011 Share Posted February 22, 2011 The DateTime format that the error message mentions is not the same as the DATETIME column type in MySQL. The manual page for the date_format function points you to the manual page for DateTime::format which tells you what it's looking for: <?php $date = date_create($row['DATETIME']); echo date_format($date,'m-d-Y'); ?> Ken Thanks mate, you've just helped me out heaps here . Quote Link to comment https://forums.phpfreaks.com/topic/228426-date_format-help/#findComment-1178040 Share on other sites More sharing options...
dflow Posted February 22, 2011 Author Share Posted February 22, 2011 thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/228426-date_format-help/#findComment-1178115 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.