0

I need to convert my "80814.89999999851" timestamp to a YY/MM/DD string. I started by doing this:

var prova = info.originalEvent.timeStamp; //this path lead to: 80814.89999999851

var prova2 = new Date(prova);

Now I have it as a datetime (if i'm not mistaken) but i don't know how to keep just the year/month/day and then convert it to a string. Can someone help me?

  • 1
    In which format is your timestamp? Spontaneously I can not think of a time format where `80814.89999999851` make sense. Its not a valid unixtime or similar i know. – foorschtbar May 17 '22 at 10:31
  • actually i don't know. I'm using fullcalendar and for various reason i'm not able to get the "info.startStr" or "info.event.startStr" (yy/mm/dd as a string) of the day selected. If i try on the console to print "info" i can see, under the "timeStamp" properties it has this value – Filippo Canino May 17 '22 at 10:35
  • Once you work out how to convert "80814.89999999851" to a *Date*, this is a duplicate of [*How to format a JavaScript date*](https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date) – RobG May 18 '22 at 04:35

1 Answers1

0

This timestamp is not seconds since unix epoch, its seconds since timeOrigin (most likely time since page was loaded), to convert it to date you need to obtain timeOrigin first. Take a look at this question: Knowing the time origin of event's timestamp.

https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp

mugiseyebrows
  • 4,138
  • 1
  • 14
  • 15