Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



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

Posts: 1,012
Location: China
Trades: 0
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!
__________________

Please login or register to view this content. Registration is FREE
- Affordable feature-packed remotely hosted message boards!

Last edited by conkermaniac; 01-22-2003 at 10:22 AM..
conkermaniac is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-22-2003, 03:28 PM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
- Everything a webmaster needs - for free

Please login or register to view this content. Registration is FREE
- Free web hosts reviewed and rated

Please login or register to view this content. Registration is FREE
- Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile
 
Old 01-23-2003, 09:07 AM
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
Trades: 0
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!
__________________

Please login or register to view this content. Registration is FREE
- Affordable feature-packed remotely hosted message boards!
conkermaniac is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP and MySQL Time and Dates
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.39205 seconds with 12 queries