Forums

PHP

This topic is locked

date formating

Posted 25 Sep 2002 17:20:58
1
has voted
25 Sep 2002 17:20:58 paul sulit posted:
hello. im reading a date column from my mysql db in the format: YYYY-MM-DD HH:MM:SS. i want to convert it to the format: Sep 24 2002 2:45:59. how do i do it? pls advise.

PS: i tried using the date_format function of PHP but i always get a mysql error. pls advise other ways. thanks.

Replies

Replied 26 Sep 2002 09:36:28
26 Sep 2002 09:36:28 Martha Graham replied:
I found a tutorial that might help you.
www.mysql.com/doc/en/Date_and_time_functions.html

Good luck.
Martha Graham
Replied 29 Sep 2002 13:40:40
29 Sep 2002 13:40:40 Iain Stewart replied:
I used Date_Format(Date,Format) as Date in my sql query, dont know if this is the best way but it seems to work for me

e.g

Select col1,col2,Date_Format(Date,'%D,%M,%Y,) AS Date
From table1

I haven't used time but look at the mysql web site for more on DATE_FORMAT and you should find what you need.

hope this helps


Iain

head hurts, 'mental note to self, stop banging head !'
Replied 12 Jan 2003 21:05:31
12 Jan 2003 21:05:31 Dean Blackborough replied:
Trying to do a similar thing on my site.

I have managed to get the Date_Time part to format correctly but I cannot select the correct data to be formated.

See attached pic.

Trying to replace 2003-01-12 with the data Updated) from my table. Can't seem to get it to work <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>

<img src="www.galleryof3d.com/site/format_list_2.jpg" border=0>

Edited by - G3D on 12 Jan 2003 21:08:08
Replied 13 Jan 2003 12:14:35
13 Jan 2003 12:14:35 Julio Taylor replied:
G3D,

Try this:
<pre id=code><font face=courier size=2 id=code>
SELECT UsernameID, Name, Status, DATE_FORMAT(Updated,'%d %m %Y') as Updated
FROM tblArtists
ORDER BY Name ASC
</font id=code></pre id=code>
this query should definetly work. please let me know if it doesn't, so i can find out if i'm really the fucking idiot that people say i am.

hope it helps!

------------------------
Julio

PHP | MySQL | UD4

ICQ: 19735247
Replied 13 Jan 2003 19:20:38
13 Jan 2003 19:20:38 Dean Blackborough replied:
Worked a charm, just had to remove the extra ' ' that I was putting around Updated. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

www.galleryof3d.com

Attempting to convert this to a database drived site - currently all individual pages. lol

Reply to this topic