Skip to content

Is there a way to render a "time since timestamp" in days as a field? #2192

Answered by ChaosNicro
ChaosNicro asked this question in Q&A
Discussion options

You must be logged in to vote

With a bit of AI-help, I hacked together this snippet, only drawback is that timestamps must be supplied in generic ISO and dates might be of by one because they account for time. Didn't fix, because JS has terrible date parsing and I don't know if API like time or moment work in Markor.

<script>
  // Define your list of timestamps and titles
  const timestampList = [
    { title: "title", timestamp: "2023-12-16" },
    { title: "title2", timestamp: "2023-11-19" },
    { title: "title3", timestamp: "2023-12-30" },
    { title: "title4", timestamp: "2023-11-28" },
    // Add more events as needed
  ];

  // Function to calculate the days between two dates
  function calculateDaysDifference…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ChaosNicro
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ChaosNicro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants