Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Date And time

Hello,

10006060*2 it's more than two hours

2 hours = 10006060*2=7200000 milliseconds. You could use google calculator to convert hours to milliseconds.

Ananya Raju
Posts: 0
Joined: Tue Oct 01, 2013 8:04 am

Date And time

hey Igor,

else if((value.getTime() - now.getTime()) < (7200000)) {
alert("within 2 hours ");
this code doesnt work when implemented... pls do tell me an alternative! it still accepts the value within the timespan of 2 hours

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Date And time

Hi Ananya,

Here is the code that takes into account the time zone offset:prevar now = new Date();
var input = new Date(Appery("mobiletextinput_24")&#46;val());
var value = new Date(input&#46;getTime() + now&#46;getTimezoneOffset() * 60000);
var difference = value&#46;getTime() - now&#46;getTime();
if (difference < 7200000) {
alert("time span selected within 2 hours");
};/prePlease note: if you need a few checks of the time difference, it is better to perform a subtraction operation once, as shown in the example, and then - just use the variable that stores a result.

Ananya Raju
Posts: 0
Joined: Tue Oct 01, 2013 8:04 am

Date And time

works perfectly THANK U!

Mohsin Khan
Posts: 0
Joined: Sat Mar 07, 2015 7:23 pm

Date And time

Hello,
Is there any function which can give a difference of the number of days or number of weeks aslo ??

I am using this in the appery.oi server code to calculate the date +280 days from a particular date

var now = new Date();
var value = new Date(input.getTime() + 241920000);

// format as JSON and return the response
response.success(JSON.stringify({
greeting: value
}), "application/json");

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Date And time

Return to “Issues”