Get current date?
Hello
I put a DATE field in my_form, fine, but i need to pre-populate/default it with the current's date, for example, if today the user has opened the form, this field should come up with todays(11/7/2011) date.
I got the code snippets from the below links, fine
http://stackoverflow.com/questions/1531093/how-to-get-current-date-in-javascript
http://www.tizag.com/javascriptT/javascriptdate.php
http://javascript.internet.com/time-date/current-date.html
code snippet is as below,
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;//January is
0!
var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd}
if(mm<10){mm='0'+mm}
var today = mm+'/'+dd+'/'+yyyy; document.write(today);
It's quite complex but it will give you todays date in the format of mm/dd/yyyy.
Simply change today = mm+'/'+dd+'/'+yyyy;
document.write(today); to what ever format you wish.
But, my requirement is,
As my_form is global, hence the date should come as per user's date format, for example. for USA its MM/DD/YYYY where as for Asia and Europe its DD-MM-YYYY
1) So, pls. let me know is there ready-made / in-built function to get my requirement
2) And am thinking to write the code in field's INITIALIZATION event, is it correct? do i need to change the event to place my code?
Thank you