calculate number of seconds between two dates

Discussion and feedback on Construct 2

Post » Sun Jul 16, 2017 10:13 am

I wrote a JS code that works well on a browser but does not work if i run it from Construct 2.

JS code :

function calc(){
var b = new Date();
var mydate = new Date('Sun Jul 16 2017 11:58:38 GMT+0300 (שעון קיץ ירושלים)');
return (b - mydate) / 1000;
}

alert(calc());

on Construct 2 :

Browser.ExecJS("
var b = new Date();
var mydate = new Date('Sun Jul 16 2017 11:58:38 GMT+0300 (שעון קיץ ירושלים)');
return parseInt((b - mydate) / 1000);")

i get always '0' but if I replace the return to alert It works well. I tried to get it back to number and text var.
B
13
S
2
Posts: 95
Reputation: 861

Return to Construct 2 General

Who is online

Users browsing this forum: Brendan2007 and 6 guests