Reply
PHP and MySQL Time and Dates
Old 01-22-2003, 08:34 AM PHP and MySQL Time and Dates
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
I am creating a PHP guestbook for the Official Jerome Flynn Website (www.jeromeflynn.com). So far, I have not encountered any problems. However, I have gotten into some trouble with dates, and being a PHP novice, I must say that I am clueless when it comes to working with dates - be it Java, VB, VBScript, or PHP. I have already checked out the PHP manual and the MySQL documentation as well - to no avail. My "PHP+MySQL for Dummies" book didn't help very much either. I would appreciate it if someone told me how to record the date and time from a computer, send it to a MySQL database, and bring it out of the database, reformatting it as "01 Jan 2000 00:00:00". I already know that I will have to use the format "d M Y H:i:s" for this, but I don't understand the deal about timestamps. Thanks in advance!
__________________
Aimoo - Affordable feature-packed remotely hosted message boards!

Last edited by conkermaniac : 01-22-2003 at 09:22 AM.
conkermaniac is offline
Reply With Quote
View Public Profile Visit conkermaniac's homepage!
 
When You Register, These Ads Go Away!
     
Old 01-22-2003, 02:28 PM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
There are a few ways of doing this. One way is to have a DATETIME field in the database. This will store the data in the format:
'0000-00-00 00:00:00' (year, month day)
To set it, INSERT a NULL value into that field.
You can then output it as if text.

Another way is to use PHP to get and format the date and time:
$thedate=("d M Y H:i:s");
then store it in a VARCHAR field.
If you still want to sort on date, you could combine both methods, using the DATETIME for sorting only.

There probably is a way to get and format data from a DATETIME, but I can't remember it just now.
__________________
Free Webmaster Help - Everything a webmaster needs - for free
Free-Webhosting.info - Free web hosts reviewed and rated
Web Hosting Hunt - Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile Visit david's homepage!
 
Old 01-23-2003, 08:07 AM
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
Hi david,

Thanks for the tips! I'm using a DATETIME field at the moment, and I'm having trouble reformatting the dates after I bring them out of the database. I think I'll set it to VARCHAR and see what happens. Thanks again!
__________________
Aimoo - Affordable feature-packed remotely hosted message boards!
conkermaniac is offline
Reply With Quote
View Public Profile Visit conkermaniac's homepage!
 
Reply     « Reply to PHP and MySQL Time and Dates
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11756 seconds with 13 queries