Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

current date and time

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hey,

I want to put the current date and time in my database. But don't know how I can get them?

I thougt:
$cDate = getdate();
$cTime = ?????

but it only puts 0000-00-00 in my database ... can someone help me? The One And Only KryptoS
 
Insufficient data for a meaningful answer. You did not specify which database backend you are using -- I will assume MySQL and answer.


MySQL expects a date to be a string of the form YYYY-MM-DD. getdate() returns an array.

You can use MySQL's "now()" function to insert the date on the database side:
INSERT INTO table_name (date_col) values (now())

You can use:
$cDate = date ('Y-m-d');
to set $cDate to a date string MySQL can use from the PHP side. Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top