Posted by MoX on 00:02:00 04-05-2002
I just wondered how to save the time of posts or stuff like that with PHP/MySQL.
I played around with some of PHP's time functions, but I could not convert any return value to MySQL DATE...How to do this? Or is DATE wrong for this task?
I really don't know, cause I'm quite new to PHP/MySQL.
[addsig]
Posted by nonama on 18:07:00 04-05-2002
best way is to use mysql field type called timestamp or something like that with len 14. then time is stored like this "yyyymmddhhmmss" without a help of your script.
Posted by KaGez on 02:23:00 04-06-2002
btw, there is a data type called "date" in PHP too....
[addsig]
Posted by MoX on 14:30:00 04-06-2002
Thank you so far guys!
[addsig]
Posted by AntiHalcyon on 15:47:00 06-14-2002
For the current date in php I just do:
$Whatever=date("Y-m-d");
If you want to check that this is correct just add:echo $Whatever;
[addsig]
Posted by KaGez on 17:33:00 06-14-2002
http://www.php.net/manual/en/function.date.php
Here you will find everything
[addsig]
Posted by MoX on 02:45:00 06-15-2002
The problem is some months old now...and as you might assume, I already found the solution
Anyway, thank you guys!
[addsig]
Posted by KaGez on 00:09:00 06-16-2002
hehe, but it will maybe help somebody else later
[addsig]
Posted by benbread on 04:33:00 04-29-2003
ok for a virtual pet/monster site i want to create (dont moan, i know theres 1000's) i want a standard time for the site that is the same in all counties, should i use the server time or is there another way, in both cases how?
Posted by HelloWorld on 23:08:00 07-20-2003
Well there are many options for date and time in both PHP and MySQL. Someone above suggested that you use a timestamp so it is automatic, this is fine, as long as you never update a field in that row, because timestamps are update upon edit.
In php check out the date() function.
In MySQL check out the date_format function.
I suggest you use a DATETIME field, and when inserting data into a row, simple add the MySQL function NOW() to add the current date and time.
I hope this helps you, if not tell me and I will try to give more help