Wrox Programmer Forums
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 8th, 2004, 09:56 AM
Authorized User
Join Date: Oct 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date object javascript


Does anyone one how to add let's say 5 hours and 30 minutes from a time?


Old September 8th, 2004, 10:29 AM
Friend of Wrox
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post


Create a Date object with the appropriate time, lets call it myDate & then do the following...

myDate.setHours(myDate.getHours() + 5, myDate.getMinutes() + 30);


Old September 10th, 2004, 10:15 AM
Authorized User
Join Date: Sep 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

create a date object:

var myDate = new Date("DATE");
add 330 minutes to the minutes currently set in myDate. This is equal to adding 5 hours and 30 minutes but you don't have to set the hours:

myDate.setMinutes(myDate.getMinutes() + 330);

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Type in JavaScript YMas Intro Programming 4 May 30th, 2008 06:58 AM
javascript and the session object VictorVictor ASP.NET 2.0 Professional 3 April 1st, 2007 02:58 PM
javascript boolean object crmpicco Javascript How-To 3 May 16th, 2006 11:50 AM
Using the Session Object and JavaScript rguidry Classic ASP Professional 10 December 23rd, 2004 05:23 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.