04-05-2007, 04:51 PM
i have a table called date_time.it has 2 fields.
i want to store the current date and current time in that table.when ever i fetch the date and time it should display the current date and current time.any of your idea will be appreciated
04-05-2007, 05:26 PM
You use the date() (http://uk2.php.net/date) function to get both the date and time. There is no need to store this if you always want to retrieve the current date and time though - you just call it whenever you need it. If however you want to store the date and time at the time when the database record was updated, then simply assemble it in whatever format you want using the date() function and store it as normal.
04-05-2007, 06:06 PM
when a user will upload files on my site,the file info will be stored in table.and it will also shows a link to the user to download or visit that file.when he visits the link,the counter in table will be incremented.on every day at a particular time i want to update the counter to zero.that's all
05-03-2007, 02:29 PM
usee.........just now() function in the insert table......it will work
Insert into tablename (column1,column2,time.) VALUES ('$_post[columnname1]','$coulmnname2',now()).....
this works defiently....
05-04-2007, 01:11 AM
This query should do it for you:
$query = "INSERT INTO `date_time` (`date`,`time`) VALUES (DATE(),TIME())";
(enlarging on what nani_s23 said)
conversely, you could just have one field for the date AND time, and use the MySQL function NOW() to get the whole timestamp.
For more, check out http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now
05-04-2007, 01:25 AM
I have always used
putenv("TZ=EST5EDT"); // Eastern Time
//putenv("TZ=AST9ADT"); // Alaskan Time
//putenv("TZ=PST8PDT"); // Pacific Time
//putenv("TZ=MST7MDT"); // Mountain Time
//putenv("TZ=CST6CDT"); // Central Time
//putenv("TZ=GMT0"); // Greenwich Mean Time
//putenv("TZ=UTC0"); // Universal Time Coordinated
This is because normally, at least when I was learning PHP, time() only used the system time.
Using the putenv() function, time() reflects the time for the timezone you would like for it to use.
If this is wrong, someone please correct me.
personally have always used now()
seems to work the best.