JavaScript DHTML/Date Time/UTC Date

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

Convert Date to UTC String

   <source lang="html4strict">
   

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


     </source>
   
  


Convert time to a UTC Date

   <source lang="html4strict">
   

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


     </source>
   
  


Get UTC Date

   <source lang="html4strict">
   

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


     </source>
   
  


Get UTC Day

   <source lang="html4strict">
   

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

                alert(myDate.getUTCDay());">Date: get UTC Day</button>

</body> </html>


     </source>
   
  


Get UTC Hours

   <source lang="html4strict">
   

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

                alert(myDate.getUTCHours());">Date: get UTC Hours</button>

</body> </html>


     </source>
   
  


Get UTC Milliseconds

   <source lang="html4strict">
   

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

                alert(myDate.getUTCMilliseconds());">Date: get UTC Milliseconds</button>

</body> </html>


     </source>
   
  


Get UTC Minutes

   <source lang="html4strict">
   

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


     </source>
   
  


Get UTC Month

   <source lang="html4strict">
   

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

                alert(myDate.getUTCMonth());">Date: GETUTCMONTH</button>

</body> </html>


     </source>
   
  


Get UTC Seconds

   <source lang="html4strict">
   

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


     </source>
   
  


Set UTC Date

   <source lang="html4strict">
   

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

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

</body> </html>


     </source>
   
  


Set UTC Full Year

   <source lang="html4strict">
   

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

                myDate.setUTCFullYear(2030); 
                alert(myDate);">Date: set UTC Full Year</button>

</body> </html>


     </source>
   
  


Set UTC Hours

   <source lang="html4strict">
   

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

                myDate.setUTCHours(11); 
                alert(myDate);">
                Date: set UTC Hours</button>

</body> </html>


     </source>
   
  


Set UTC Milliseconds

   <source lang="html4strict">
   

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

                myDate.setUTCMilliseconds(20); 
                alert(myDate);">Date: set UTC Milliseconds</button>

</body> </html>


     </source>
   
  


Set UTC Minutes

   <source lang="html4strict">
   

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

                myDate.setUTCMinutes(22); 
                alert(myDate);">

Date: set UTC Minutes </button> </body> </html>


     </source>
   
  


Set UTC Month

   <source lang="html4strict">
   

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

                myDate.setUTCMonth(2); 
                alert(myDate);">
                Date: set UTC Month

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


     </source>
   
  


Set UTC Seconds

   <source lang="html4strict">
   

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

                myDate.setUTCSeconds(12); 
                alert(myDate);">Date: set UTC Seconds</button>

</body> </html>


     </source>