Pfan.date = {//return timestamp gettimestamp:function () {var timestamp=new date (). GetTime (); return timestamp.tostring (); },//timestamp to date format//@nS timestamp getlocaltime:function (NS) {return new date (parseint (NS) *). Tolocalestrin g (). substr (0,17); },//@time, time, such as new date (' 2013/11/10 0:12:12 ')//@pre, week prefix, such as: Week, week//@ Nums, such as: 123456 days getweek:functi On (time, pre, nums) {//# gets day of the week time = typeof time = = ' string '? This.parse (Time): (Time | | new Date ()); Pre = Pre | | ' Week '; Zhou Nums = nums | | ' Day 123456 '; Return pre + Nums[time.getday ()]; },//@formatType: YYYY, YY, MM//@ time:new date (' 2013/11/12 ')//@weeks: Day 123456 format:function (Formatt Ype, time, weeks) {//formatted output times var pre = ' 0 ', formattype = Formattype | | ' Yyyy-mm-dd ', weeks = Weeks | | ' Day 123456 ', time = Time | | New Date (); Format time return (Formattype | | "). Replace (/yyyy| Yyyy/g, time.getFullYear ()). Replace (/yy| Yy/g, Tydic.string.addPre (Pre, time.getfullyear ()%), 2). Replace (/mm| Mm/g, Tydic.string.addPre (Pre, Time.getmonth () + 1, 2)). Replace (/m| M/g, Time.getmonth () + 1). Replace (/dd| Dd/g, Tydic.string.addPre (Pre, Time.getdate (), 2)). Replace (/d| D/g, Time.getdate ()). Replace (/hh| Hh/g, Tydic.string.addPre (Pre, Time.gethours (), 2)). Replace (/h| H/g, Time.gethours ()). Replace (/ii|ii/g, Tydic.string.addPre (Pre, Time.getminutes (), 2)). Replace (/I | I/g, Time.getminutes ()). Replace (/ss| Ss/g, Tydic.string.addPre (Pre, Time.getseconds (), 2)). Replace (/s| S/g, Time.getseconds ()). Replace (/w/g, Time.getday ()). Replace (/w/g, Weeks[time.getday ()]); } }
Script Date format conversion