How do I calculate the date and time with the timestamp?
var blockTime = Date.UTC(2014, 7, 11, 2, 0, 0, 0) + timestamp * 1000;
@Daforce np, and just as added bonus :) the timestamps on blockchain are from the genesis block creation time ;) thats why we need to get that time first.
hi guy i need your help faucet could not access wallet what will i do
timestamp * 1000
Is the timestamp in µs?
@LithStud mhhh.... I think there is something wrong.
Date.UTC() returns milliseconds and the timestamp is in seconds. So it should be:
var blockTime = Date.UTC(2014, 7, 11, 2, 0, 0, 0) * 1000+ timestamp;
Also i figured out that the date is one month off
2014/07/11T02:00:00 is the timestamp 1405044000 in seconds.
If I take a transaction timestamp from my wallet
2/27/2017 09:09:31= 80464171
then I would get the Date
1405044000 + 80464171 =1485508171
1485508171 = 01/27/2017 09:09:31
So the correct genesis date is 2014/08/11T02:00:00
Thx for the help, I´m now able to calculate date,time and timeframes :D
@Daforce Date.UTC returns miliseconds so no need to multiply by 1000, while timestamp is in seconds and needs to be converted to milisenconds before adding to Date.UTC
and no the month is good
The Date.UTC() method accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time.
Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]])
A year after 1900.
An integer between 0 and 11 representing the month.
Optional. An integer between 1 and 31 representing the day of the month.
Optional. An integer between 0 and 23 representing the hours.
Optional. An integer between 0 and 59 representing the minutes.
Optional. An integer between 0 and 59 representing the seconds.
Optional. An integer between 0 and 999 representing the milliseconds.
A number representing the number of milliseconds in the given Date object since January 1, 1970, 00:00:00, universal time.
how to check?
get current timestamp from -> https://wallet.burst-team.us:8128/burst?requestType=getTime (at time of writing its 80478405) var blockTime = Date.UTC(2014, 7, 11, 2, 0, 0, 0) + 80478405 * 1000; var currentDate = new Date(blockTime); console.log(currentDate.toUTCString());
"Mon, 27 Feb 2017 13:06:45 GMT"
EDIT: Changed so it shows UTC time without timezone adjustement
and for testing convenience https://codepen.io/LithStud/pen/mWJXyr
@LithStud thanks fo all the afford in helping me.
Timestamp genesisBlock = Timestamp.valueOf("2014-07-11 02:00:00.0"); Date date = new Date(genesisBlock.getTime()+(long)80478405*1000); System.out.println(date);
Fri Jan 27 12:06:45 CET 2017
One month behind.
Timestamp genesisBlock = Timestamp.valueOf("2014-08-11 04:00:00.0"); Date date = new Date(genesisBlock.getTime()+(long)80478405*1000); System.out.println(date);
Mon Feb 27 14:06:45 CET 2017 ¯\_(ツ)_/¯