By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,686 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

datetime format

P: 17
hi Everyone.
Can anyone tell me how to change date format from mySql format to english like followings.

value in db is 2007-05-19 00:00:00
and I want it to be displayed in the following format.
May 19 2007
How can I achieve that.
thanks in advance.
May 26 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 5,821
Take a look at date and strtotime.
May 26 '07 #2

P: 11
I've been struggling with this also having entered a time with NOW() into a field called place_date and then been unable to format it.
The answer I have found which may not be the best but it works is as follows:

Expand|Select|Wrap|Line Numbers
  1. $mysqli = mysqli_connect("localhost", "user", "password", "db")
  3. $get = SELECT DATE_FORMAT(place_date,' %b %e %Y ' ) AS fmt_place_date
  4.           FROM table
  5.           WHERE...;
  7. $get_res = mysqli_query($myqsli,$get);
  9. $date = $get_res[' fmt_place_date'];
  11. echo $date;
[Please use CODE tags when posting source code. Thanks! --pbmods]

This is mostly cribbed from Julie Meloni's book PHP, MySQL and APACHE which, as a beginner, I have found very useful. (I don't know whether I'm allowed to say this but it's a genuine comment from the UK, not a promotional fluff!)
May 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.