Jump to content

Adding date to hidden field


rmt123

Recommended Posts

Hi
i hope someone can help me, i am still very new to coding

[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]strOutput += "<TD CLASS=\"entry\<input type=hidden name=Date value="???????????"></TD>";[!--colorc--][/span][!--/colorc--]

is the above code correct so far and what do i have to replace ????????????????? with so that it will save todays date (and time if possible) into my database

anyone who can help me please greatly appreciated

regards
scottt
Link to comment
https://forums.phpfreaks.com/topic/8627-adding-date-to-hidden-field/
Share on other sites

Hi there,

To get the date using javascript,, you could try something like:
[code]
<html>
<body>

<script>
var d=new Date();
</script>

<table>
<tr>
<td><input type=hidden name=Date id=Date></td>
</tr>
</table>

<script>
document.getElementById('Date').setAttribute("value",d);
// debug line:
alert('date is: '+document.getElementById("Date").getAttribute("value"));
</script>
</body>
</html>
[/code]

Some tips (hmm, maybe in french,,) on this site: [a href=\"http://www.asp-php.net/tutorial/scripting/dates.php\" target=\"_blank\"]date functions & javascript[/a]

But you will need to use php/Mysql to save the dates into your database,...

So, better use php like:
1- get the date with php date function,
2- save it using mysql into a database

Hoping it helps,

l8tr,,

Archived

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

×
×
  • Create New...

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.