javascript Conversation

      No Comments on javascript Conversation

javascript Conversation

javascript conversation

javascript conversion functions.

  • Number() : this method is used to convert data into Number
  • parsetInt() : this method is used to convert data into integer type of number
  • parseFloat() : this method is used to convert data into Float type of number.
  • valueOf() : this method is used to convert string to number.

 

How to Generate Random Number between 0 to 99 in JavaScript ?

Math.random() * 100;

 

How to create Date Variable in JavaScript ? how javascript conversation is used ?

In JavaScript date is calculated in miliseconds, but you can use following constructor to create date object. be sure to assign month -1 as month is value is considered as index value (possible values : 0 – 11)

 

<script>
   var mydt = new Date(2015,0,13);
   document.write(mydt);
   //Tue Jan 13 2015 00:00:00 GMT+0530 (India Standard Time)
</script>

 

How to extract day, month, year, hour, minute and second from data using JavaScript ?

<script>
   var mydt = new Date(2015,0,13,10,11,12);
   document.write(mydt.getDate());         // 13
   document.write(mydt.getMonth());        // 0 (be sure about this)
   document.write(mydt.getFullYear());     // 2015
   document.write(mydt.getHours());        // 10
   document.write(mydt.getMinutes());      // 11
   document.write(mydt.getSeconds());      // 12
</script>

Leave a Reply