View Full Version : Date/Time
12-31-2003, 12:14 AM
I want to store dates and times in a database, and have one field in the table to store the actuall date, and have another determine how it is formatted. Then using php I want to display the date/time using the information provided in the database. How do I go about doing this?
12-31-2003, 03:09 AM
Use the date_format function, store how the person wants it show in the field, like D/M/Y, or m/d/Y, add % infront of each letter (%D/%M/%Y for example) then do something like this in the query
SELECT DATE_FORMAT(datefield,'$user->dateformat') AS datefield WHERE user='$username'
12-31-2003, 04:06 AM
But what goes in the other field? (The one that stores the date/time informaion, and NOT the field that stores its format). And how do I recieve that information using a php script? (That information being current date/time).
12-31-2003, 04:10 AM
You'd use the date() (http://www.php.net/date) function
Depending on how your database field is
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.