JavaScript DHTML/Date Time/UTC Date

Материал из Web эксперт
Версия от 07:19, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Convert Date to UTC String

    
<html>
<body>
<button onclick="var myDate = new Date(); alert(myDate.toUTCString());">toUTCString</button>
</body>
</html>



Convert time to a UTC Date

    
<html>
<body>
<button onclick="var myDate = new Date(); alert(Date.UTC(myDate));">UTC</button>
</body>
</html>



Get UTC Date

    
<html>
<body>
<button onclick="var myDate = new Date(); alert(myDate.getUTCDate());">
Date: get UTC Date
</button>
</body>
</html>



Get UTC Day

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 alert(myDate.getUTCDay());">Date: get UTC Day</button>
</body>
</html>



Get UTC Hours

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 alert(myDate.getUTCHours());">Date: get UTC Hours</button>
</body>
</html>



Get UTC Milliseconds

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 alert(myDate.getUTCMilliseconds());">Date: get UTC Milliseconds</button>
</body>
</html>



Get UTC Minutes

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



Get UTC Month

    
<html>
<body>
<button onclick="var myDate = new Date(); 
                 alert(myDate.getUTCMonth());">Date: GETUTCMONTH</button>
</body>
</html>



Get UTC Seconds

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



Set UTC Date

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



Set UTC Full Year

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



Set UTC Hours

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



Set UTC Milliseconds

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



Set UTC Minutes

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



Set UTC Month

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



Set UTC Seconds

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