Hi,
I have a form on my website, which needs a date entry in the format YYYYMMDD, however I need this to be the current date in South Korea, not the current date on the users PC whatever country / time zone he happens to be at the time.
The code for the form is as follows, with the value “today” representing the date in question: –
<form action=”
<input name=”opsDd” type=”hidden” id=”opsDd” value=today>
<p align=”center”>
<!–webbot bot=”Validation” b-value-required=”TRUE” i-minimum-length=”5″ i-maximum-length=”5″ –><input name=”trnNo” id=”trnNo” style=”font-family: Arial; font-weight: bold” size=”5″ maxlength=”5″>
</p>
<p align=”center”>
<input type=”submit” value=”Submit” style=”font-family: Arial; font-weight: bold”>
</p>
</form>
The code generating the date value “today” at present is as follows: –
<script type=”text/javascript”>
window.onload=function(){
for(var i=0,dd=document.getElementsByName(‘opsDd’);i<dd.length;i++)
dd[i].value=Date.set();
}
Date.set=function(){
var today=new Date(); // Create a date object and assign to variable “today”
return today.getFullYear()+((today.getMonth()<10)?’0’+
(today.getMonth()+1): (today.getMonth()+1))+today.getDate();
}
</script>