View Full Version : Date/Time Stamp

07-31-2008, 06:40 PM
Hello folks this might be a newbie question but I was wondering if there was a way to automatically insert a date or time stamp or both into a database from a hiddenfield in a form. When I inserted the hidden field all I get is a Value box with a lighting bolt next to us. Do I need to put some kind of date and time thing in mysql database to be able to get this and put it in its value?

Any help is awesome!

07-31-2008, 08:21 PM
if i'm not misunderstood your question, you can put value="<?php time()?>" (or whatever, check here (http://nl2.php.net/date)) in the hidden field.

07-31-2008, 08:22 PM
ah yes... any clue about asp? haha sorry I should have stated that before.

08-01-2008, 01:04 AM
none but in mysql timestamp will update every time the record is updated (if null value). i would think ,though not sure it is more a attribute of the database. not sure this helps

08-01-2008, 06:22 PM
date <%response.write(date())%>
time <%response.write(time())%>

08-04-2008, 02:27 PM
date <%response.write(date())%>
time <%response.write(time())%>

Could you write this like this and have it still work?


How would you combine the two?

08-04-2008, 03:05 PM
never mind I got it and it worked thanks for your help guys!

08-04-2008, 03:21 PM
never mind I got it and it worked thanks for your help guys! I'm sure other people reading this thread would mind :-) What was your solution?

08-04-2008, 03:35 PM
oh sry about that. It was nothing special I just both response.write methods to a variable and did another response.write that passed the variable to display it in my database. I just found out that DW also lets you set a hidden value to multiple asp lines of code. like this

vale="<% response.write(date()) %>, <%response.write(time())%>"

This makes a nice little time stamp for me whenever a user uploads something to our server we are able to view the timestamp in the database.

prob not the best way but it works!

08-04-2008, 03:48 PM
i am not an asp'er but is this not valid

vale="<% response.write(date() && time()) %>"

with && being your concatination operator (not sure its right though)

08-04-2008, 03:53 PM
Nope i tried that first thinking it would be the same as in java or other languages but i got a Microsoft VBScript compilation error '800a03ea'

08-04-2008, 04:00 PM
what about ....

<% = now %>

08-04-2008, 04:06 PM
or this even

<% Response.Write(FormatDateTime(Now(),2) & FormatDateTime(Now(),4) ) %>

08-04-2008, 04:07 PM
yup this is perfect! better then the other way! Thanks David! you are always helping me out I'm going to have to give you some credit in my internship paper I have to write by the end of this month!

08-04-2008, 04:08 PM
now actually gave me both date and time and saved some character space

08-04-2008, 04:12 PM
nice one

high five