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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding date to a hidden field 1

Status
Not open for further replies.

jedel

Programmer
Jan 11, 2003
430
AU
I can't believe I'm asking this question. I thought it would have been located in this forum. Possibly been answered so Long ago that it is so far back in the archives that nobody goes there anymore. But here it as anyway.

I have a form where data is entered into a MySQL database. I also have two fields that record the last person to edit the record and the date he edited it.

I can get the username of the person into the hidden field easy enough as it is taken from the session data. However I cannot seem to get a date into the field. I only get "0/00/00"

So how do we get a date (formatted as "dd-mmm-yy" into a date field in a MySQL database?

Would it be easier to make the date field a text field and have the date display in this format, but as text?

-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
 
MySQL has a built-in field type, that will update the time whenever a record is updated. I think this is what you're looking for. This would avoid storing any date anywhere. Look into TIMESTAMP.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Nice work! take a star.

Next question, is there a way to change the format? ie dd-mmm-yy hh:mm:ss

-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
 
The time and date get stored in the database like that. The format you pull them out completely depends on what you need. Check DATE_FORMAT() to see what can MySQL output as a date for you.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top