JavaScript DHTML/Date Time/Date Set

Материал из Web эксперт
Перейти к: навигация, поиск

Set Date

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setDate(20); 
                alert(myDate);">Date: set Date</button>

</body> </html>


     </source>
   
  


Set Full Year

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setFullYear(2000); 
                alert(myDate);">
                Date: set Full Year
                </button>

</body> </html>


     </source>
   
  


Set Hours

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setHours(12); 
                alert(myDate);">Date: set Hours</button>

</body> </html>


     </source>
   
  


Set Milliseconds

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setMilliseconds(845); 
                alert(myDate);">
                Date: set Milliseconds
                </button>

</body> </html>


     </source>
   
  


Set Minutes

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setMinutes(2); 
                alert(myDate);">
                Date: set Minutes</button>

</body> </html>


     </source>
   
  


Set Month

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setMonth(5); 
                alert(myDate);">
                Date: set Month</button>

</body> </html>


     </source>
   
  


Set Seconds

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setSeconds(20); 
                alert(myDate);">Date: set Seconds

</button> </body> </html>


     </source>
   
  


Set Time

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setTime(myDate.getTime()); 
                alert(myDate);">Date: set Time</button>

</body> </html>


     </source>
   
  


Set Year

   <source lang="html4strict">
   

<html> <body> <button onclick="var myDate = new Date();

                myDate.setYear(2000); 
                alert(myDate);">Date set year</button>

</body> </html>


     </source>