From 5e9cc27c11b5ad66775403c6dfcf62d8bf7c9abf Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 6 Nov 2015 09:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=BD=9C=E4=B8=9A=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=8F=91=E5=B8=83=E6=97=A5=E6=9C=9F=E8=8B=A5=E6=9C=AA?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=88=99=E9=BB=98=E8=AE=A4=E4=B8=BA=E5=BD=93?= =?UTF-8?q?=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/course.js | 17 ++++++++++++++++- public/javascripts/new_user.js | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/public/javascripts/course.js b/public/javascripts/course.js index b015af857..0c7f4156f 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -663,7 +663,7 @@ function regex_homework_end_publish_time() var myDate = new Date(); if($.trim($("#homework_publish_time").val()) == "") { - $("#homework_publish_time").val(myDate.getFullYear()+'-'+(myDate.getMonth()+1)+'-'+myDate.getDate()); + $("#homework_publish_time").val(formate_date(myDate)); } var publish_time = Date.parse($("#homework_publish_time").val()); var end_time = Date.parse($("#homework_end_time").val()); @@ -695,6 +695,21 @@ function regex_homework_end_time() } } +function formate_date(date){ + var str = ""; + var year = date.getFullYear(); + var month = date.getMonth() + 1; + var day = date.getDate(); + if(month < 10) { + month = '0' + month; + } + if(day < 10) { + day = '0' + day; + } + str = year + '-' + month + '-' + day; + return str; +} + //验证发送到课程 function regex_course_id(){ var course_id = $("#course_id").val(); diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index 4cf380523..ca7b28ee7 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -97,7 +97,7 @@ function regex_homework_end_publish_time() var myDate = new Date(); if($.trim($("#homework_publish_time").val()) == "") { - $("#homework_publish_time").val(myDate.getFullYear()+'-'+(myDate.getMonth()+1)+'-'+myDate.getDate()); + $("#homework_publish_time").val(formate_date(myDate)); } var end_time = Date.parse($("#homework_end_time").val()); var publish_time = Date.parse($("#homework_publish_time").val()); @@ -129,6 +129,21 @@ function regex_homework_end_time() } } +function formate_date(date){ + var str = ""; + var year = date.getFullYear(); + var month = date.getMonth() + 1; + var day = date.getDate(); + if(month < 10) { + month = '0' + month; + } + if(day < 10) { + day = '0' + day; + } + str = year + '-' + month + '-' + day; + return str; +} + //验证发送到课程 function regex_course_id(){ var course_id = $("#course_id").val();