javascriptwhatsappwhatsapi

WhatsApp lastseen function how to


In order to retrieve the lasteen information for specific contact from whatsApp web interface I run the following code in Chrome 63.xx build it retrieves the following information highlighted with code. But I don't know how to interpret it, I suspect that t: 1513932466 value at the end is the format for data and time, which is written in integer format.

So my question is how to translate that into something as human readable format such as date + time ?

Store.Wap.lastseenFind("phone_number" + '@c.us').then(function(r){ console.log(r)})

t {_flags: 0, 
   _value: undefined, 
   _onFulfilled: ƒ, 
   _onRejected: undefined,
   _context: undefined, 
   …}control: undefined
   x: undefined_child: undefined_children: undefined_context: 
   undefined_control: undefined_flags: 5_onFulfilled: ƒ (r)_onRejected: 
   undefined_parent: undefined_resolveLevel: 2_thenableParent: null_value: 
   undefined__proto__: Object
   VM36:1 {t: 1513932466}
   t: 1513932466__proto__: Object

Solution

  • I'm not sure what Whatsapp returns, but the numeric value you have given is a unix timestamp and you can convert it to a human readable date format using almost any of the languages you use.

    Since you have used Javascript, this is how to convert your timestamp to a date format.

    You need to multiply the timestamp by 1000 to convert it to milliseconds.

    var timestamp = 1513932466;
    var datetime = new Date(timestamp * 1000);
    
    console.log(datetime);
    

    Hope it helps! Feel free to ask if you need to know anything :)