Solved

Is within time range?

Posted on 2011-09-21
1
173 Views
Last Modified: 2012-06-27
Paypal is going to have an outage between 11:30PM PDT and 4:00AM PDT on Sept 24 and 25, 2011.

I want to be able to throw a dialog that notifies my customers that their purchases may not go through due to this outage and they must try again later.

How would I tell if the time, I know, using JavaScript, it will be the client's computer time, is between the time frame above?
0
Comment
Question by:EddieShipman
1 Comment
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 36575184
just convert it to milliseconds, it will become easier

var d1 = new Date();
d1.setDate(24);
d1.setMonth(8);
d1.setFullYear(2011);
d1.setHours(23);
d1.setMinutes(30);

var d2 = new Date();
d2.setDate(25);
d2.setMonth(8);
d2.setFullYear(2011);
d2.setHours(4);
d2.setMinutes(0);

var currentTime = new Date();
var currentTimeMS = currentTime.getTime();


if ( d1.getTime() < currentTimeMS && d2.getTime() > currentTimeMS )
{
   alert("this is the correct time");
}
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question