/    Sign up×
Community /Pin to ProfileBookmark

Generating current date for South Korea for use in form

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>

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@cbVisionSep 25.2008 — 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
×

Success!

Help @jt42cwr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...