You are reading a single comment by @dapgo and its replies. Click here to read the full conversation.
  • After some testing I've realize that epoch time from Date.now() and returned from setWatch() are different, and yes it is documented that 2nd one is using float.

    I wanted to see in human readable format, and i can do for the result of Date.now(), ie:

    console.log("now "+Date.now());
    //1677093816456.81469726562
    var keyDate = new Date(Date.now());    
    console.log("converted Date.now",keyDate);   
    //Wed Feb 22 2023 20:23:36 GMT+0100     OK
    

    But I have problems with console.log when using the float from setWatch()

    setWatch( function(btnx) {
        console.log("time "+btnx.time);
        //1677093816.43038654327
        console.log("time *1000 "+btnx.time*1000);
        //1677093816430.38647460937        
        var pressDate = new Date(btnx.time*1000);
        console.log("pressDate "+pressDate);
        //1677093816430.38647460937    WHY???
      }
      ,BTN1, {repeat:true, edge:'falling'}
    );
    

    On the other hand, from the IDE console, when i assign the previous float*1000 to a var I can see a human readable value, i.e

     var miDate = new Date(1677093816.43038654327*1000);
        //Feb 22 2023 20:23:36 GMT+0100  OK
    
        console.log("miDate "+miDate);
        // 1677093816430.38647460937   WHY????  
    

    I am sure that there is an easy explanation and my issue is causes from the lack of theoretical basics.

About

Avatar for dapgo @dapgo started