2

is the code:

var time = new Buffer('506BF1E3','hex');
time.toString() //'Pk��'

0x506BF1E3 = 1349251555 unixtime;

How get '1349251555' form time Buffer?

3 Answers 3

6

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));
Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

0

this will do the trick:

var time = new Buffer('506BF1E3','hex');
console.log(parseInt("0x"+time.toString("hex")));

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.