Jump to content

Archived

This topic is now archived and is closed to further replies.

Noctagon

date/now **solved**

Recommended Posts

I am attempting to set up a variable so that it equals the current date and time so that I can send that to the database when an item is added so i know when it was added.

How do I do this?

Thanks :)

Share this post


Link to post
Share on other sites
if you're wanting it in the typical SQL DATETIME format (YYYY-MM-DD HH:MM:SS), just use this:
[code]
<?php
$ts = date('Y-m-d h:i:s');
?>
[/code]

however, if your SQL field is a DATETIME or other like datatype, why not just use the SQL function NOW()?

Share this post


Link to post
Share on other sites
Make sure you have a field for the time in your table, and then just do "UPDATE TABLE SET TIME=NOW() WHERE ..."

Share this post


Link to post
Share on other sites
[quote author=obsidian link=topic=109490.msg441403#msg441403 date=1159231752]
if you're wanting it in the typical SQL DATETIME format (YYYY-MM-DD HH:MM:SS), just use this:
[code]
<?php
$ts = date('Y-m-d h:i:s');
?>
[/code]
[/quote]

Thanks, that worked perfectly :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.