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 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 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 . 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 Link to comment https://forums.phpfreaks.com/topic/228426-date_format-help/#findComment-1178115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.