You are here: irt.org | FAQ | JavaScript | Date | Q147 [ previous next ]
The following subtracts five hours from the current date and time:
<SCRIPT LANGUAGE = 'JavaScript'><!-- function y2k(number) { return (number < 1000) ? number + 1900 : number; } var date = new Date(); var date = new Date(Date.UTC(y2k(date.getYear()),date.getMonth(),date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds()) - 5*60*60*1000); document.write(date); //--></SCRIPT>