Date (read) Methods

[Total: 0    Average: 0/5]

This shows how to use the Date object with all of it’s read-type methods.

Body Code:

<script type=text/javascript>
function w(_s,_w) { document.write(_s+'='+_w+'<br>'); }
var _d = new Date();
w('Date',_d.getDate());
w('Day',_d.getDay());
w('FullYear',_d.getFullYear());
w('Hours',_d.getHours());
w('Milliseconds',_d.getMilliseconds());
w('Minutes',_d.getMinutes());
w('Month',_d.getMonth());
w('Seconds',_d.getSeconds());
w('Time',_d.getTime());
w('Timezoneoffset',_d.getTimezoneOffset());
w('UT-Date',_d.getUTCDate());
w('UT-Day',_d.getUTCDay());
w('UT-FullYear',_d.getUTCFullYear());
w('UT-Hours',_d.getUTCHours());
w('UT-Milliseconds',_d.getUTCMilliseconds());
w('UT-Minutes',_d.getUTCMinutes());
w('UT-Month',_d.getUTCMonth());
w('UT-Seconds',_d.getUTCSeconds());
w('Year',_d.getYear());
var _months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
document.write('<BR><BR>The month is = '+_months[_d.getMonth()]);
</script>

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *