Javascript Date function in details - 2

Advertisemen


Examples :
var d = new Date();
getDate()
Returns the day of the month 
d.getDate()= current month [between 0-11]
getDay()
Returns the day of the week 
d.getDay()= Day of the week [between 1-7]
getFullYear()
Returns the year
d.getFullYear()= Current year [2016]
getHours()
Returns the hour 
d.getHours()= between [0-23]
getMilliseconds()
Returns the milliseconds 
d.getMilliseconds()= between [0-999]
getMinutes()
Returns the minutes
d.getMinutes()= between [0-59]
getMonth()
Returns the month
d.getMonth()= between [0-11]
getSeconds()
Returns the seconds 
d.getSeconds()= between [0-59]
getTime()
Returns the number of milliseconds since midnight Jan 1 1970, and a specified date
d.getTime()= 1467886730618
getTimezoneOffset()
Returns the time difference between UTC time and local time, in minutes
d.getTimezoneOffset() = -600
getUTCDate()
Returns the day of the month, according to universal time
d.getUTCDate() = 7 [right now 7 July 2016]
getUTCDay()
Returns the day of the week, according to universal time
d.getUTCDay() = between [0-6]
getUTCFullYear()
Returns the year, according to universal time
d.getUTCFullYear() = 2016 [current year]
getUTCHours()
Returns the hour, according to universal time
d.getUTCHours()= between [0-23]
getUTCMilliseconds()
Returns the milliseconds, according to universal time
d.getUTCMilliseconds()= between [0-999]
getUTCMinutes()
Returns the minutes, according to universal time 
d.getUTCMinutes()= between [0-59]
getUTCMonth()
Returns the month, according to universal time 
d.getUTCMonth()= between [0-11]
getUTCSeconds()
Returns the seconds, according to universal time
d.getUTCSeconds()= between [0-59]
now()
Returns the number of milliseconds since midnight Jan 1, 1970
d.now() = 1467887680820
parse()
Parses a date string and returns the number of milliseconds since January 1, 1970
d.parse("January 1, 2016") = 1451566800000
setDate()
Sets the day of the month of a date object
d.setDate(2) = Sat Jul 2 2016 20:37:57 GMT+1000 (AEST)
setFullYear()
Sets the year of a date object
d.setFullYear(2030) = Tue Jul 07 2030 20:40:00 GMT+1000 (AEST)
setHours()
Sets the hour of a date object
d.setHours(20)= Thu Jul 07 2016 20:40:49 GMT+1000 (AEST)
setMilliseconds()
Sets the milliseconds of a date object
d.setMilliseconds(150)
d.getMilliseconds()= 150
setMinutes()
Set the minutes of a date object
d.setMinutes(21) = Thu Jul 07 2016 20:21:20 GMT+1000 (AEST)
setMonth()
Sets the month of a date object
d.setMonth(5) = Sat Jun 07 2016 20:44:22 GMT+1000 (AEST)
setSeconds()
Sets the seconds of a date object
d.setSeconds(55) = Thu Jul 07 2016 20:45:55 GMT+1000 (AEST)
setTime()
Sets a date to a specified number of milliseconds after/before January 1, 1970
d.setTime(1332403882588) = Thu Mar 22 2012 19:11:22 GMT+1100 (AEDT)
setUTCDate()
Sets the day of the month of a date object, according to universal time
d.setUTCDate(2) = Sat Jul 2 2016 20:37:57 GMT+1000 (AEST)
setUTCFullYear()
Sets the year of a date object, according to universal time
d.setUTCFullYear(2030) = Tue Jul 07 2030 20:40:00 GMT+1000 (AEST)
setUTCHours()
Sets the hour of a date object, according to universal time
d.setUTCHours(20)= Thu Jul 07 2016 20:40:49 GMT+1000 (AEST)
setUTCMilliseconds()
Sets the milliseconds of a date object, according to universal time
d.setUTCMilliseconds(150)
d.getUTCMilliseconds()= 150
setUTCMinutes()
Set the minutes of a date object, according to universal time
d.setUTCMinutes(21) = Thu Jul 07 2016 20:21:20 GMT+1000 (AEST)
setUTCMonth()
Sets the month of a date object, according to universal time
d.setUTCMonth(5) = Sat Jun 07 2016 20:44:22 GMT+1000 (AEST)
setUTCSeconds()
Set the seconds of a date object, according to universal time
d.setUTCSeconds(55) = Thu Jul 07 2016 20:45:55 GMT+1000 (AEST)
toDateString()
Converts the date portion of a Date object into a readable string
d.toDateString() = Thu Jul 07 2016
toISOString()
Returns the date as a string, using the ISO standard
d.toISOString()= 2016-07-07T10:51:47.405Z
toJSON()
Returns the date as a string, formatted as a JSON date
d.toJSON() = 2016-07-07T10:52:22.736Z
toLocaleDateString()
Returns the date portion of a Date object as a string, using locale conventions
d.toLocaleDateString()= 07/07/2016
toLocaleTimeString()
Returns the time portion of a Date object as a string, using locale conventions
d.toLocaleTimeString() = 20:53:27
toLocaleString()
Converts a Date object to a string, using locale conventions
d.toLocaleString() = 07/07/2016, 20:53:58
toString()
Converts a Date object to a string
d.toString() = Thu Jul 07 2016 20:54:26 GMT+1000 (AEST)
toTimeString()
Converts the time portion of a Date object to a string
d.toTimeString() = 20:54:56 GMT+1000 (AEST)
toUTCString()
Converts a Date object to a string, according to universal time
d.toUTCString() = Thu, 07 Jul 2016 10:55:30 GMT
UTC()
Returns the number of milliseconds in a date since midnight of January 1, 1970, according to UTC time
Date.UTC(2012,02,30) = 1333065600000
valueOf()
Returns the primitive value of a Date object
d.valueOf() = 1467888993253


 Source : www.w3schools.com


Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D