Script Date format conversion

Source: Internet
Author: User
Tags timestamp to date

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.