I've been looking for some ways to get the system date and the date & string format to convert each other, but the overall self-feeling is the following way more appropriate.
If there is a better way, hope that we have a lot of comments and exchanges, thank you!
2016 wrote once, but just sent a bit of code, yesterday think of the blog park, log in after viewing the damage can not be opened, I said very sorry,
Also look ahead to see the friends do not open a lot of forgive!
"No forwarding sharing without my permission, thank you!" 】
--------------------------------------------------------------------------------------------------------------- --
Convert string to date format:
Page Submission Date Processing
function Send () {
var EndDate = window.document.getElementById ("EndDate"). Value;
Convert a date to a string
var enddatetx = enddate.tostring ();
if (Enddatetx! = "") {
Date Style (YYYY/MM/DD) converted to string style (YYYY-MM-DD)
Window.document.getElementById ("Enddatetx"). Value = Enddatetx.replace (/\//g, "-");
}else{
Window.document.getElementById ("Enddatetx"). Value = "";
}
}
--------------------------------------------------------------------------------------------------------------- --
Date converted to string format:
The Echo load date, provided that the Date field in the page has its field formatted as date and the style is YYYY/MM/DD
function OnLoad () {
var EndDate = window.document.getElementById ("EndDate"). Value;
if (EndDate! = "") {
string format (YYYY-MM-DD) to convert to date format (YYYY/MM/DD)
var Enddaterx = Enddate.replace (/-/g, "/");
Window.document.getElementById ("Enddaterx"). Value = Enddaterx;
}else{
Window.document.getElementById ("Enddaterx"). Value = "";
}
}
Note: replace () application and precautions, you can go to view the relevant information, there are many online.
JS processing Date & string format to convert each other