doddsey_65 Posted September 3, 2011 Share Posted September 3, 2011 Having used unix timestamps in the past formatting the date used to be easy. But since converting to mysql DATETIME im struggling to format it properly. I basically pull the date from the database, convert it using strtotime(), then convert it to a date using date(). The problem is that when i use 'a' to display am/pm the time almost always says am. If the time is 11am then it will display 11am. If it's 12pm then it will display 12pm, but if it comes to 1pm and above it will revert back to 1am. This is the date string I use: date('jS M Y g:i a'); is this due to the fact that mysql DATETIME uses 24 hour clock ('H'), if so is there a way around this? Quote Link to comment https://forums.phpfreaks.com/topic/246341-formatting-date/ Share on other sites More sharing options...
voip03 Posted September 3, 2011 Share Posted September 3, 2011 Try without space between i and a Your code date('jS M Y g:i a'); New code date('jS M Y g:ia'); eg. echo date("D jS F Y G:ia", strtotime($row['date']))."<br/>"; Quote Link to comment https://forums.phpfreaks.com/topic/246341-formatting-date/#findComment-1265056 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.