PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Jul 04, 2020 1:10 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Tue Dec 14, 2004 11:15 am 
Offline
Forum Commoner

Joined: Fri Jun 18, 2004 4:38 am
Posts: 49
Location: England, UK
Hi,

I'm storing dates in a SQL database using smalldatetime.

When I pull the date out of the database and print it, it appears as eg. "2004-12-14 14:50:00"

I want it to look like "14th December 2004 2:50pm"

How the hell do I convert it? I've spent all afternoon looking through SQL forums and experimenting with the date() function but I am obviously missing something fundamental as I only get a load of nonsense whenever I try to convert it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 11:34 am 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
If the db in question is MySQL you might want to check their man page on [mysql_man]date_format[/mysql_man] function


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 11:46 am 
Offline
Forum Commoner

Joined: Fri Jun 18, 2004 4:38 am
Posts: 49
Location: England, UK


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 12:21 pm 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
then you may find useful


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 4:21 am 
Offline
Forum Commoner

Joined: Fri Jun 18, 2004 4:38 am
Posts: 49
Location: England, UK
OK, thanks. :)

So if my query currently reads:

Syntax: [ Download ] [ Hide ]
<?php



$query = "SELECT * FROM Posts WHERE (PostID='{$_GET['PostID']}')";



?>


How do I go about incorporating the extra information shown in that article?

Would it be easier to have a separate query to get the date or its it possible to do the whole thing at once?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 4:40 am 
Offline
Forum Contributor

Joined: Fri Jul 09, 2004 1:23 am
Posts: 422


Last edited by AGISB on Wed Dec 15, 2004 4:40 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 4:40 am 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 5:45 am 
Offline
Forum Commoner

Joined: Fri Jun 18, 2004 4:38 am
Posts: 49
Location: England, UK


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 6:13 am 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 5:21 am 
Offline
Forum Commoner

Joined: Fri Jun 18, 2004 4:38 am
Posts: 49
Location: England, UK


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group