Page 1 of 2
Date And time
Posted: Tue Oct 29, 2013 6:46 am
by Ananya Raju
this is my layout... i have used a input component and i have used the type as date and time local... i need a script that would help me to perform action on the time set by the user.....i need to display an alert if a user selects a time in the next 3 hours of the current time ie. if the time is 13.00 and in the input box if he selects a time as 14.00 i need to display a alert saying "time span selected within 3 hours"...i dont want any action to be performed on the else part....and i also need to show an alert if the time or date entered in the input box that "the date has expired".... could u pls help me out with this problem
Date And time
Posted: Tue Oct 29, 2013 6:50 am
by Ananya Raju
in short i need to compare the current date and time with the selected date and time by the user in the inpbx for the 3 hours timespan if the selected time is within the 3 hours time span of the current time then display an alert...and also if a user selects a date which is already expired then also display a alert
Date And time
Posted: Tue Oct 29, 2013 3:07 pm
by maxkatz
Please share or post the app public link.
Date And time
Posted: Wed Oct 30, 2013 4:23 am
by Ananya Raju
http://appery.io/app/mobile-frame?src...
its in the travel page...
pls do help me at the earliest its under priority based project
Date And time
Posted: Wed Oct 30, 2013 8:03 am
by Kateryna Grynko
Hi Ananya,
You can use the following code:
prevar value = new Date(Appery("mobiletextinput_10").val());
var now = new Date();
if ((value.getTime() - now.getTime()) < (10006060*3)){
alert("time span selected within 3 hours");
}/pre
Date And time
Posted: Wed Oct 30, 2013 11:49 am
by Ananya Raju
Could u pls explain to me the logic of that code pls!
Date And time
Posted: Wed Oct 30, 2013 11:54 am
by Ananya Raju
and what about the date which is already passed? if i select a date which has already passed then i want the alert to say " Date already passed"
Date And time
Posted: Wed Oct 30, 2013 12:11 pm
by Ananya Raju
if ((value.getTime() - now.getTime()) < (100060603)) this line of code could u pls explain..... that value of 100060603 why is it used? n how did u calculate that value for time could u pls explain that for me?
Date And time
Posted: Wed Oct 30, 2013 2:18 pm
by Kateryna Grynko
Ananya,
1000 ms in a second
60 seconds in a minute
60 minutes in a hour
3 hours
To know whether the time is passed take a look at the sign of the subtraction result:
preif (value.getTime() - now.getTime() < 0)
{
alert("Date already passed");
}/pre
Date And time
Posted: Thu Oct 31, 2013 5:08 am
by Ananya Raju
if i were to calculate the time span for two hours then wat should i do? just change the 100060603 to 100060602? will it work?