MySQL Date Problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

MySQL Date Problems

Post by tecktalkcm0391 »

MySQL Database wants a datetime input for one of its fields, but I don't know how to convert the time() method's output into this format. Any help?

PS. I add on time to the time returned by time().... so I can't just use NOW()
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: MySQL Date Problems

Post by jaoudestudios »

php time() is the unix time stamp and is the best date & time format to save, as it can easily be converted back to any date format. Real easy to do calculation and differences.

S0 you have a long number? What format do you want it in?

Some examples...
http://www.jaoudestudios.com/timestamp.php
pkbruker
Forum Commoner
Posts: 32
Joined: Sun Aug 03, 2008 9:36 am
Location: Oslo, Norway

Re: MySQL Date Problems

Post by pkbruker »

Store the return value of time() in a BIGINT field in the database.
Post Reply