Solved

Is within time range?

Posted on 2011-09-21
1
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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 …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

636 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