Noctagon Posted September 26, 2006 Share Posted September 26, 2006 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 :) Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 26, 2006 Share Posted September 26, 2006 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()? Quote Link to comment Share on other sites More sharing options...
Tandem Posted September 26, 2006 Share Posted September 26, 2006 Make sure you have a field for the time in your table, and then just do "UPDATE TABLE SET TIME=NOW() WHERE ..." Quote Link to comment Share on other sites More sharing options...
Noctagon Posted September 26, 2006 Author Share Posted September 26, 2006 [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 :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.