Skip to content

Commit

Permalink
add getCurrentDate
Browse files Browse the repository at this point in the history
  • Loading branch information
coding-and-trading committed Nov 30, 2017
1 parent ca229b5 commit 94d5f4c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions CompanyCommonTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ var ajaxHelper = (function () {
})();

var dateHelper = (function () {
var getDateObj, getDateFromString, getDateTime, getCurrentDate;
// 根据传入的dateTime String(例如: 2017/08/31 11:59:59)返回date(例如: 2017-08-31)
var getDateObj = function (dateStr) {
getDateObj = function (dateStr) {
if (null == dateStr || undefined == dateStr) {
return null;
}
Expand All @@ -77,15 +78,15 @@ var dateHelper = (function () {
return new Date(dateStr);
};

var getDateFromString = function (dateStr) {
getDateFromString = function (dateStr) {
var date = getDateObj(dateStr);
return date ? null: date.getFullYear() + '-' + (date.getMonth() + 1)
+ '-' + date.getDate();
};


// 根据传入的dateTime String(例如: 2017/08/31 11:59:59)返回date(例如: 2017-08-31 11:59:59)
var getDateTime = function (dateStr) {
getDateTime = function (dateStr) {
var date = getDateObj(dateStr);

return date ? null: date.getFullYear() + '-'
Expand All @@ -97,9 +98,17 @@ var dateHelper = (function () {

};

// 返回当前时间
getCurrentDate = function () {
var date1 = new Date();
return date1.getFullYear() + '-' + date1.getMonth() + '-' + date1.getDay() + ' '
+ date1.getHours() + ':' + date1.getMinutes() + ':' + date1.getSeconds();
};

return {
getDateFromString: getDateFromString,
getDateTime: getDateTime
getDateTime: getDateTime,
getCurrentDate: getCurrentDate
};
})();

Expand Down

0 comments on commit 94d5f4c

Please sign in to comment.