I've a code as follows -
auto time = std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1);
var d = new Date(time)
[...] is it safe to assume that if I replace auto with
longtype, the variable will still store the correct amount of milliseconds across different machines?
No, you need a signed integer type of at least 45 bits, which
long is not guarantee to be. You should use
using namespace std::chrono; milliseconds::rep time = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
Also note that in term of portability, the
system_clock's epoch is not guaranteed to be January 1st 1970 00:00:00 UTC by the standard (even if it is the cast most of the time).