Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
is the code:
var time = new Buffer('506BF1E3','hex'); time.toString() //'Pk��'
0x506BF1E3 = 1349251555 unixtime;
How get '1349251555' form time Buffer?
time
This one will do the trick as well. Convert hex to int by calling parseInt with radix argument 16:
var time = new Buffer('506BF1E3','hex'); console.log(parseInt(time.toString('hex'), 16));
Add a comment
Use this? Seems much better than parsing...
time.readUInt32BE(0)
However, I think you need to make sure that this is always 4 bytes (32-bits), otherwise it will fail.
this will do the trick:
var time = new Buffer('506BF1E3','hex'); console.log(parseInt("0x"+time.toString("hex")));
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.