Date. prototype. format = function (FMT) {// Author: meizz var o = {"m +": This. getmonth () + 1, // month "d +": This. getdate (), // Day "H +": This. gethours (), // Hour "m +": This. getminutes (), // minute "s +": This. getseconds (), // second "q +": math. floor (this. getmonth () + 3)/3), // quarter "S": This. getmilliseconds () // millisecond}; If (/(Y + )/. test (FMT) FMt = FMT. replace (Regexp. $1, (this. getfullyear () + ""). substr (4-Regexp. $1. Length); For (var k in O) if (New Regexp ("(" + K + ")"). test (FMT) FMt = FMT. replace (Regexp. $1, (Regexp. $1. length = 1 )? (O [k]): ("00" + O [k]). substr ("" + O [k]). length); Return FMT;} date. prototype. adddays = function (d) {This. setdate (this. getdate () + d) ;}; date. prototype. addweeks = function (w) {This. adddays (w * 7) ;}; date. prototype. addmonths = function (m) {var d = This. getdate (); this. setmonth (this. getmonth () + M); If (this. getdate () <D) This. setdate (0) ;}; date. prototype. addyears = function (y) {var M = This. getmonth (); this. setfullyear (this. getfullyear () + Y); If (M <this. getmonth () {This. setdate (0) ;}}; var now = new date (); now. adddays (1); // add or subtract a date to operate alert (now. format ("yyyy-mm-dd"); posted @ Jacky song read (184) Comments (0) edit the category of the favorite excerpt: Javascript