Advertisement
RokiAdhytama

DateTime - Chapter 12-1

Jul 4th, 2022
1,475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html xmlns = "http://www.w3.org/1999/xhtml">
  2.    <head>
  3.       <title>Date and Time Methods</title>
  4.  
  5.       <script type = "text/javascript">
  6.          <!--
  7.          var current = new Date();
  8.                  
  9.          document.writeln(
  10.             "<h1>String representations and valueOf</h1>" );
  11.          document.writeln( "toString: " + current.toString() +
  12.             "<br />toLocaleString: " + current.toLocaleString() +
  13.             "<br />toUTCString: " + current.toUTCString() +
  14.             "<br />valueOf: " + current.valueOf() );
  15.                    
  16.          document.writeln(
  17.             "<h1>Get methods for local time zone</h1>" );
  18.          document.writeln( "getDate: " + current.getDate() +
  19.             "<br />getDay: " + current.getDay() +  
  20.             "<br />getMonth: " + current.getMonth() +    
  21.             "<br />getFullYear: " + current.getFullYear() +    
  22.             "<br />getTime: " + current.getTime() +    
  23.             "<br />getHours: " + current.getHours() +    
  24.             "<br />getMinutes: " + current.getMinutes() +    
  25.             "<br />getSeconds: " + current.getSeconds() +    
  26.             "<br />getMilliseconds: " +
  27.             current.getMilliseconds() +
  28.             "<br />getTimezoneOffset: " +
  29.             current.getTimezoneOffset() );  
  30.                      
  31.          document.writeln(
  32.             "<h1>Specifying arguments for a new Date</h1>" );
  33.          var anotherDate = new Date( 2001, 2, 18, 1, 5, 0, 0 );
  34.          document.writeln( "Date: " + anotherDate );
  35.          
  36.          document.writeln(
  37.             "<h1>Set methods for local time zone</h1>" );
  38.          anotherDate.setDate( 31 );
  39.          anotherDate.setMonth( 11 );
  40.          anotherDate.setFullYear( 2001 );
  41.          anotherDate.setHours( 23 );
  42.          anotherDate.setMinutes( 59 );
  43.          anotherDate.setSeconds( 59 );
  44.          document.writeln( "Modified date: " + anotherDate );
  45.          // -->
  46.       </script>
  47.  
  48.    </head><body></body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement