computermax2328 Posted August 16, 2012 Share Posted August 16, 2012 Hello Again, I am building a blog and for every time I post in my database I have an auto time stamp that is attached to every entry. When I output the date and time just as a variable I get Y-m-d. Then I tried to use date_format() command. Now I am getting a blank. How can I rearrange my $date variable to the format I need? This is what I used: $date = $row['Date']; $date = date_format("m/d/Y", $date); Quote Link to comment https://forums.phpfreaks.com/topic/267159-php-output-date/ Share on other sites More sharing options...
requinix Posted August 16, 2012 Share Posted August 16, 2012 Use DATE_FORMAT(). Which you said you tried but apparently there was something wrong. 1. What did you try? 2. Are you storing the dates as actual DATETIME columns? Or some other type? Quote Link to comment https://forums.phpfreaks.com/topic/267159-php-output-date/#findComment-1369817 Share on other sites More sharing options...
Barand Posted August 16, 2012 Share Posted August 16, 2012 If it's a DATE or DATETIME field use $date = date_format("m/d/Y", strtotime($date)); Quote Link to comment https://forums.phpfreaks.com/topic/267159-php-output-date/#findComment-1369828 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.