Click to See Complete Forum and Search --> : Generating current date for South Korea for use in form


jt42cwr
09-21-2008, 05:27 AM
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="http://logis.korail.go.kr/driveinfo/TrainInfop.jsp" method="get">
<input name="opsDd" type="hidden" id="opsDd" value=today>
<p align="center">
&nbsp;<!--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>

cbVision
09-25-2008, 10:13 AM
Try this link, it looks like you can specify by which timezone.
http://www.javascriptmall.com/jsc/jsC4Udate.htm#DateTime13

I think you have to use the function:
getTimeZoneOffset()
...and then work off of that.

Here's another link:
http://www.comptechdoc.org/independent/web/cgi/javamanual/javadate.html