Timestamp format
-
How do I calculate the date and time with the timestamp?
-
@Daforce for JavaScript
var blockTime = Date.UTC(2014, 7, 11, 2, 0, 0, 0) + timestamp * 1000;
-
@LithStud thx
-
@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
-
-
@Daforce its only for javascript as it deals in miliseconds
-
@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= 80464171then I would get the Date
1405044000 + 80464171 =14855081711485508171 = 01/27/2017 09:09:31So 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.
Syntax
Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]])
Parameters
year
A year after 1900.
month
An integer between 0 and 11 representing the month.
day
Optional. An integer between 1 and 31 representing the day of the month.
hour
Optional. An integer between 0 and 23 representing the hours.
minute
Optional. An integer between 0 and 59 representing the minutes.
second
Optional. An integer between 0 and 59 representing the seconds.
millisecond
Optional. An integer between 0 and 999 representing the milliseconds.Return value
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());prints out
"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.
I see that your Javascript code does the right things with the date given but it does not in Java.Example:
Timestamp genesisBlock = Timestamp.valueOf("2014-07-11 02:00:00.0"); Date date = new Date(genesisBlock.getTime()+(long)80478405*1000); System.out.println(date);Output:
Fri Jan 27 12:06:45 CET 2017One month behind.
it works.
Timestamp genesisBlock = Timestamp.valueOf("2014-08-11 04:00:00.0"); Date date = new Date(genesisBlock.getTime()+(long)80478405*1000); System.out.println(date);Output:
Mon Feb 27 14:06:45 CET 2017 ¯\_(ツ)_/¯
-
@Daforce ahh you should of said your using Java and not JavaScript ;) Java date library is different :) i think it uses just seconds and probably months are 1-12 not 0-11 as in JavaScript ;) thats why month off

