下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 js时间操作方法大全集锦完整版(JS time operation method Daquan …

js时间操作方法大全集锦完整版(JS time operation method Daquan Daquan complete version).doc

js时间操作方法大全集锦完整版(JS time operati…

SamanthaOK
2018-12-25 0人阅读 举报 0 0 暂无简介

简介:本文档为《js时间操作方法大全集锦完整版(JS time operation method Daquan Daquan complete version)doc》,可适用于社会民生领域

js时间操作方法大全集锦完整版(JStimeoperationmethodDaquanDaquancompleteversion)js时间操作方法大全集锦完整版(JStimeoperationmethodDaquanDaquancompleteversion)Date(对象)Date对象能够使你获得相对于国际标准时间(格林威治标准时间,现在被称为UTCUniversalTimeCoordinated)或者是Flash播放器正运行的操作系统的时间和日期要使用date对象的方法,你就必须先创建一个date对象的实体(Instance)Date对象必须使用或以后版本的播放器FlashDate对象的方法并不是静态的,但是在使用时却可以应用于所指定的单独实体Date:对象的方法简介getdate,根据本地时间获取当前日期(本月的几号)getday,根据本地时间获取今天是星期几(Sunday,Monday)getfullyear,根据本地时间获取当前年份(四位数字)gethours,根据本地时间获取当前小时数(小时制,)getmilliseconds,根据本地时间获取当前毫秒数getminutes,根据本地时间获取当前分钟数getmonth,根据本地时间获取当前月份(注意从开始:JanFeb,,)getseconds,根据本地时间获取当前秒数gettime,获取utc格式的从以来的毫秒数:gettimezoneoffset,获取当前时间和utc格式的偏移值(以分钟为单位)getutcdate,获取utc格式的当前日期(本月的几号)getutcday,获取utc格式的今天是星期几(Sunday,Monday)getutcfullyear,获取utc格式的当前年份(四位数字)getutchours,获取utc格式的当前小时数(小时制,)getutcmilliseconds,获取utc格式的当前毫秒数getutcminutes,获取utc格式的当前分钟数getutcmonth,获取utc格式的当前月份(注意从开始:JanFeb,,)getutcseconds,获取utc格式的当前秒数getyear,根据本地时间获取当前缩写年份(当前年份减去)setdate,设置当前日期(本月的几号)setfullyear,设置当前年份(四位数字)sethours,设置当前小时数(小时制,)setmilliseconds,设置当前毫秒数setminutes,设置当前分钟数setmonth,设置当前月份(注意从开始:JanFeb,,)setseconds,设置当前秒数settime,设置utc格式的从以来的毫秒数:setutcdate,设置utc格式的当前日期(本月的几号)setutcfullyear,设置utc格式的当前年份(四位数字)setutchours,设置utc格式的当前小时数(小时制,)setutcmilliseconds,设置utc格式的当前毫秒数setutcminutes,设置utc格式的当前分钟数setutcmonth,设置utc格式的当前月份(注意从开始:Jan,Feb)ThesecondsetUTCSeconds,settheUTCformatnumberSetYearsetyear(currentyearminus)ToString,thedateandtimevaluesareconvertedinto"stringdatetimevaluesintheformofDateUTC,UTCreturnsthespecifieddateandtimeformatfixedtimevalueCreateanewDateobjectSyntax:New,Date()NewDate(year,month,date,hour,minute,second,millisecond)Parameter:Yearisanintegerbetweenand,correspondingtoto,oraspecifiedyearforthefourdigitnumberMonthisanintegerbetween(Jan)to(December),andthisparameterisoptionalDateisanintegerbetweenand,andthisparameterisoptionalHourisanintegerbetween(:am)to(:pm),andthisparameterisoptionalMinuteisanintegerbetweenand,andthisparameterisoptionalSecondisanintegerbetweenand,andthisparameterisoptionalMillisecondisanintegerbetweenand,andthisparameterisoptionalNotes:ObjectCreateanewDateobjectPlayersupport:FlashorlaterExample:Here'sanexampleofgettingthecurrentdateandtime:Now=new,Date()CreateanexampleoftheDateobjectforthenationalday:Nationalday=new,Date(,,)Next,afteryoucreateanewDateobject,usethegetMonth,getDate,andgetFullYearmethodsoftheDateobjecttogetthetime,andthenoutputtheexampleinthedynamictextboxMyDate=new,Date()DateTextField=(mydategetMonth()""myDategetDate()""mydategetFullYear())Date>DategetDateDategetDateSyntax:myDategetDate()Parameter:NoneNotes:Method。Getsthecurrentdatebasedonthelocaltime(numberofthismonth),andthereturnvalueisanintegerbetweenandPlayersupport:FlashorlaterDate>DategetDayDategetDaySyntax:myDategetDay()Parameter:NoneNotes:Method。Accordingtothelocaltime,whatdayistoday(,Sunday,,Monday,)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DategetFullYearDategetFullYearSyntax:myDategetFullYear()Parameter:NoneNotes:Method。Getsthecurrentyearbasedonthelocaltime(fourdigits,suchas)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterExample:ThefollowingexamplecreatesanewDateobject,andthenoutputstheyearintheoutputwindowinthegetFullYearmethod:MyDate=new,Date()Trace(myDategetFullYear())Date>DategetHoursDategetHoursSyntax:myDategetHours()Parameter:NoneNotes:Method。Getsthecurrentnumberofhoursbasedonthelocaltime(hoursystem,andreturnsanintegerbetween)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DategetMillisecondsDategetMillisecondsSyntax:myDategetMilliseconds()Parameter:NoneNotes:Method。Getsthecurrentnumberofmillisecondsbasedonthelocaltime(thereturnvalueisanintegerbetweenand)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DategetMinutesDategetMinutesSyntax:myDategetMinutes()Parameter:NoneNotes:Method。Getsthecurrentnumberofminutesbasedonthelocaltime(thereturnvalueisanintegerbetweenand)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DategetMonthDategetMonthSyntax:myDategetMonth()Parameter:NoneNotes:Method。Getthecurrentmonthaccordingtothelocaltime(Note:startfrom:,Jan,,February)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DategetSecondsDategetSecondsSyntax:myDategetSeconds()Parameter:NoneNotes:Method。Getsthecurrentnumberofsecondsbasedonthelocaltime(thereturnvalueisanintegerbetweenand)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DategetTimeDategetTimeSyntax:myDategetTime()Parameter:NoneNotes:Method。InUTCformat,returnsthenumberofmillisecondsfrom:aminJanuary,tonowThismethodcandescribethesameinstantoftimeindifferenttimezonesPlayersupport:FlashorlaterDate>DategetTimezoneOffsetDategetTimezoneOffsetSyntax:mydategetTimezoneOffset()Parameter:NoneNotes:Method。Getstheoffsetvalue(inminutes)ofthecurrenttimeandtheUTCformatPlayersupport:FlashorlaterExample:ThefollowingexamplereturnstheoffsetbetweentheBeijingtimeandtheUTCtimeNewDate()GetTimezoneOffset()Theresultsareasfollows:(hours*minuteshour=minutes)Date>DategetUTCDateDategetUTCDateSyntax:myDategetUTCDate()Parameter:NoneNotes:Method。GetsthecurrentdateoftheUTCformat(thenumberofthismonth)Playersupport:FlashorlaterDate>DategetUTCDayDategetUTCDaySyntax:myDategetUTCDate()Parameter:NoneNotes:Method。WhatdayistodayinUTCformat(Sunday,,Monday,)Playersupport:FlashorlaterDate>DategetUTCFullYearDategetUTCFullYearSyntax:myDategetUTCFullYear()Parameter:NoneNotes:Method。Getsthecurrentyear(fourdigitnumber)intheUTCformatPlayersupport:FlashorlaterDate>DategetUTCHoursDategetUTCHoursSyntax:myDateGetUTCHours()Parameter:NoneNotes:Method。GetsthecurrentnumberofhoursintheUTCformat(hours,andreturnsanintegerbetween)Playersupport:FlashorlaterDate>DategetUTCMillisecondsDategetUTCMillisecondsSyntax:myDategetUTCMilliseconds()Parameter:NoneNotes:Method。GetsthecurrentnumberofmillisecondsintheUTCformat(thereturnvalueisanintegerbetweenand)Playersupport:FlashorlaterDate>DategetUTCMinutesDategetUTCMinutesSyntax:myDategetUTCMinutes()Parameter:NoneNotes:Method。GetsthecurrentnumberofminutesintheUTCformat(thereturnvalueisanintegerbetweenand)Playersupport:FlashorlaterDate>DategetUTCMonthDategetUTCMonthSyntax:myDategetUTCMonth()Parameter:NoneNotes:Method。GetsthecurrentmonthinUTCformat(notefrom:,Jan,,February,)Playersupport:FlashorlaterDate>DategetUTCSecondsDategetUTCSecondsSyntax:myDategetUTCSeconds()Parameter:NoneNotes:Method。GetsthecurrentnumberofsecondsintheUTCformat(thereturnvalueisanintegerbetweenand)Playersupport:FlashorlaterDate>DategetYearDategetYearSyntax:myDategetYear()Parameter:NoneNotes:Method。Getsthecurrentabbreviatedyearbasedonthelocaltime(minusforthecurrentyear)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsIn,forexample,wasusedPlayersupport:FlashorlaterDate>DatesetDateDatesetDateSyntax:myDatesetDate(date)Parameter:dateisanintegerbetweenandNotes:Method。Setthecurrentdatebasedonlocaltime(numberofthismonth)LocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DatesetFullYearDatesetFullYearSyntax:myDatesetFullYear(year,month,date)Parameter:Thefourbitintegerspecifiedbytheyearrepresentsthespecifiedyear,andthetwodigitdoesnotrepresenttheyearForexample,doesnotmean,butonlyforadMonthisanintegerfrom(Jan)to(December),andthisparameterisoptionalDateisanintegerfromto,andthisparameterisoptionalNotes:Method。SettheyearaccordingtolocaltimeIfthemonthanddateparametersareset,boththemonthandthedatearesetatthesametimeLocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsAftersetting,thevaluesobtainedbythegetUTCDayandgetDaymethodschangeaccordinglyPlayersupport:FlashorlaterDate>DatesetHoursDatesetHoursSyntax:myDatesetHours(hour)Argument:hourisanintegerfrom(:am)to(:pm)Notes:Method。SetsthecurrenthouraccordingtothelocaltimeLocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DatesetMillisecondsDatesetmilliseconds语法:mydatesetmilliseconds(millisecond)参数:millisecond是一个从到之间的整数注释:方法根据本地时间设置当前毫秒数本地时间由flash播放器所运行的操作系统决定播放器支持:flash或以后版本date>datesetminutesdatesetminutes语法:mydatesetminutes(minute)参数:petite是一个从到之间的整数注释:方法根据本地时间设置当前分钟数本地时间由flash播放器所运行的操作系统决定播放器支持:flash或以后版本date>datesetmonthdatesetmonth语法:mydatesetmonth(monthgiven)参数:month是一个从(一月)到(十二月)之间的整数given是一个从到之间的整数,这个参数是可选的注释:方法根据本地时间设置当前月份数,如果选用了dates参数,将同时设定日期本地时间由flash播放器所运行的操作系统决定播放器支持:flash或以后版本date>datesetsecondsdatesetseconds语法:mydatesetseconds(second)参数:second是一个从到之间的整数注释:方法根据本地时间设置当前秒数本地时间由flash播放器所运行的操作系统决定播放器支持:flash或以后版本date>datesettimedatesettime语法:mydatesettime(millisecond)参数:millisecond是一个从到之间的整数注释:方法用毫秒数来设定指定的日期播放器支持:flash或以后版本date>datesetutcdatedatesetutcdate语法:mydatesetutcdate(date)参数:dates是一个从到之间的整数注释:方法按utc格式设定日期,使用本方法将不会影响dates对象的其他字段的值,但是getutcday和getday方法会返回日期更改过后相应的新值播放器支持:flash或以后版本date>datesetutcfullyeardatesetutcfullyear语法:mydatesetutcfullyear(yearmonthgiven)参数:year代表年份的四位整数,如month一个从(一月)到(十二月)之间的整数,可选参数given一个从到之间的整数,可选参数注释:方法按utc格式设定年份,如果使用了可选参数,还同时设定月份和日期设定过后getutcday和getday方法会返回一个相应的新值播放器支持:flash或以后版本date>datesetutchoursdatesetutchours语法:mydatesetutchours(hourminutesecondmillisecond))参数:hour是一个从(:am)到():pm)之间的整数petite是一个从到之间的整数,可选参数second是一个从到之间的整数,可选参数Millisecondisanintegerbetweenand,withoptionalargumentsNotes:Method。SetsthenumberofhoursintheUTCformatIftheoptionalparameterisused,theminutes,seconds,andmillisecondsaresetPlayersupport:FlashorlaterDate>DatesetUTCMillisecondsDatesetUTCMillisecondsSyntax:myDatesetUTCMilliseconds(millisecond)Argument:millisecondisanintegerbetweenandNotes:Method。SetthenumberofmillisecondsintheUTCformatPlayersupport:FlashorlaterDate>DatesetUTCMinutesDatesetUTCMinutesSyntax:myDatesetUTCMinutes(minute,second,millisecond))Parameter:Minuteisanintegerbetweenand,withoptionalargumentsSecondisanintegerbetweenand,withoptionalargumentsMillisecondisanintegerbetweenand,withoptionalargumentsNotes:Method。SetthenumberofminutesintheUTCformatIfyouuseoptionalarguments,yousetsecondandmillisecondvaluesatthesametimePlayersupport:FlashorlaterDate>DatesetUTCMonthDatesetUTCMonthSyntax:myDatesetUTCMonth(monthdate)Parameter:Monthisanintegerfrom(Jan)to(December)Dateisanintegerfromto,andthisparameterisoptionalNotes:Method。SetthemonthoftheUTCformat,andoptionallysetthedateAftersetting,thegetUTCDayandgetDaymethodsreturnthecorrespondingnewvaluesPlayersupport:FlashorlaterDate>DatesetUTCSecondsDatesetUTCSecondsSyntax:myDatesetUTCSeconds(secondmillisecond))Parameter:Secondisanintegerbetweenand,withoptionalargumentsMillisecondisanintegerbetweenand,withoptionalargumentsNotes:Method。SetsthenumberofsecondsintheUTCformat,andsetsthemillisecondvaluewithoptionalargumentsPlayersupport:FlashorlaterDate>DatesetYearDatesetYearSyntax:myDatesetYear(year)Argument:yearisafourbitintegerrepresentingtheyear,suchasNotes:Method。SettheyearaccordingtolocaltimeLocaltimeisdeterminedbytheoperatingsystemthattheFlashplayerrunsPlayersupport:FlashorlaterDate>DatetoStringDatetoStringSyntax:myDatetoString()Parameter:NoneNotes:Method。ConvertsthedatetimevaluetoastringvalueintheformofdatetimePlayersupport:FlashorlaterExample:Thefollowingexampleoutputsthenationaldayobjectofthenationaldayintoareadablestring:VaR,nationalday=newDate(,,,,)Trace(nationaldaytoString())Output(for,Pacific,Standard,Time):Theresultswere:Sat,Oct,::,GMTDate>DateUTCDateUTCSyntax:DateUTC(year,month,date,hour,minute,second,millisecond)Parameter:Yearrepresentsthefourbitintegeroftheyear,suchasMonthanintegerfrom(Jan)to(December)Dateanintegerfromto,optionalargumentsHourisanintegerfrom(:am)to(:pm)Minuteisanintegerbetweenand,withoptionalargumentsSecondisanintegerbetweenand,withoptionalargumentsMillisecondisanintegerbetweenand,withoptionalargumentsNotes:Method。ReturnsthenumberofmillisecondsfromtheJanuary,:amatthespecifiedtimeThisisastaticmethodthatdoesnotrequireaparticularobjectItisabletocreateanewDateobjectinUTCformat,andnewDate()createstheDateobjectofthelocaltimePlayersupport:Flashorlater

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/20

js时间操作方法大全集锦完整版(JS time operation method Daquan Daquan complete version)

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利