Javascript -- Math&Date

Math.random()   //returns a random number betwen 0 and 1

Math.min() & Math.max();

Math.round(): rounds a number to the nearest integer

    Math.round(4.6);   //returns 5

    Math.round(4.4);   //returns 4

Math.ceil() & Math.floor();

====

*4 ways of initiating a date:

  *new Date(); new Date(milliseconds); new Date(dateString); new Date(year,month,day,hours,minutes,seconds,milliseconds);

*toUTCString(): converts a date to a UTC string

<script>
   var d = new Date();
   var dStr = d.toUTCString();
</script>

*Common methos of Date:

  getDate():     Get the day as a number (1-31)

  getDay():    Get the weekday as a number (0-6)

  getFullYear():  Get the four digit year (yyyy)

  getHours():   Get the hour (0-23)

  getMilliseconds():Get the milliseconds (0-999)

  getMinutes():     Get the minutes (0-59)

  getMonth():    Get the month (0-11)

  getSeconds():    Get the seconds (0-59)

  getTime():         Get the time (milliseconds since January 1, 1970)

posted on 2016-04-22 16:10  yeatschen  阅读(65)  评论(0编辑  收藏  举报

导航