JavaScript DHTML/Date Time/Date Set — различия между версиями

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

Текущая версия на 07:19, 26 мая 2010

Set Date

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setDate(20); 
                 alert(myDate);">Date: set Date</button>
</body>
</html>



Set Full Year

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setFullYear(2000); 
                 alert(myDate);">
                 Date: set Full Year
                 </button>
</body>
</html>



Set Hours

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setHours(12); 
                 alert(myDate);">Date: set Hours</button>
</body>
</html>



Set Milliseconds

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setMilliseconds(845); 
                 alert(myDate);">
                 Date: set Milliseconds
                 </button>
</body>
</html>



Set Minutes

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setMinutes(2); 
                 alert(myDate);">
                 Date: set Minutes</button>
</body>
</html>



Set Month

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setMonth(5); 
                 alert(myDate);">
                 Date: set Month</button>
</body>
</html>



Set Seconds

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setSeconds(20); 
                 alert(myDate);">Date: set Seconds
</button>
</body>
</html>



Set Time

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setTime(myDate.getTime()); 
                 alert(myDate);">Date: set Time</button>
</body>
</html>



Set Year

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 myDate.setYear(2000); 
                 alert(myDate);">Date set year</button>
</body>
</html>