现在的位置: 首页 > 综合 > 正文

jquery日期转换

2018年05月28日 ⁄ 综合 ⁄ 共 1379字 ⁄ 字号 评论关闭

  • ============看代码============================================================
  • (function($) {  
  •     $.extend({  
  •         myTime: {  
  •              
  •             DateToUnix: function(year, month, day, hour, minute, second){
     
  •                 var oDate new Date(Date.UTC(parseInt(year),
     
  •                         parseInt(month),  
  •                         parseInt(day),  
  •                         parseInt(hour),  
  •                         parseInt(minute),  
  •                         parseInt(second)  
  •                     )  
  •                 );  
  •                 return (oDate.getTime()/1000);
     
  •             },  
  •              
  •             UnixToDate: function(unixTime, isFull, timeZone){
     
  •                 if (typeof(timeZone) == 'number')
     
  •                 {  
  •                     unixTime parseInt(unixTime) parseInt(timeZone) 60 60;
     
  •                 }  
  •                 var time new Date(unixTime*1000);
     
  •                 var ymdhis "";
     
  •                 ymdhis += time.getUTCFullYear() "-";
     
  •                 ymdhis += time.getUTCMonth() "-";
     
  •                 ymdhis += time.getUTCDate();  
  •                 if isFull === true )
     
  •                 {  
  •                     ymdhis += " time.getUTCHours() ":";
     
  •                     ymdhis += time.getUTCMinutes() ":";
     
  •                     ymdhis += time.getUTCSeconds();  
  •                 }  
  •                 return ymdhis;
     
  •             }  
  •         }  
  •     });  
  • })(jQuery);
  • 抱歉!评论已关闭.