1

I want to get the expiration time of a product of webpage and change it to unix time using javascript date methods....

  var expiration = document.querySelector('span#bigDealTimer1');
  //with this selector I can get the time-counter.

  expiration = expiration && expiration.innerText;


how can i change the expiration time in the span to unix Time ? (time is decreasing to zero)

Alireza_Ez73
  • 139
  • 2
  • 8

1 Answers1

3

Although I don't know what kind of format the date/time will be in, there's the standard Date library you can use for parsing your string date value to a UNIX timestamp.

const unixTimeZero = Date.parse('01 Jan 1970 00:00:00 GMT');

Ref - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

denchie
  • 41
  • 2