1

Our codes are done on C#. However, I use javascript for e2e tests. For a particular variable, it is based on DateTime.UtcNow.Ticks . It used to be based on DateTime.UtcNow

My previous js script just simply use the following declaration:

const date = new Date();
const dateNow = date.toISOString();

This is based on a suggested solution in this thread: How do I get a UTC Timestamp in JavaScript?

I need the dateNow on a string format based on UTC Ticks.

ebanster
  • 886
  • 1
  • 12
  • 29
  • What are "UTC Ticks"? *Date.now()* returns a time value in milliseconds since 1970-01-01T00:00:00Z, which is a commonly used epoch. To get a value in integer seconds just divide by 1,000: `secs = Date.now() / 1000 | 0`. – RobG Apr 07 '20 at 08:03
  • If you have a time value in seconds that is an offset from the ECMAScript epoch, then `new Date(secs * 1e3).toISOString()` will do the job. PS. many of the answers at the link you provided are wrong or misleading. – RobG Apr 07 '20 at 08:20
  • I used this and seem to work fine. Thanks. – ebanster Apr 07 '20 at 14:47

0 Answers0