question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I can’t find a way to make it work with UNIX timestamps. Is it possible or did you cut off this feature?

Moment.js states you can do moment.unix(value).format("MM/DD/YYYY") but how can I do this with your filter?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mcescalantecommented, Jun 9, 2017

I just ran into this same issue and did some digging and found a nice simple fix. As you mentioned,moment itself as a library supports unix timestamps with moment.unix(). I installed moment, imported it, and added a filter into my component to do Unix timestamps for me:

Vue component

filters: {
  formatUnix: function (value) {
    if (value) {
      return moment.unix(value).format('MM-DD-YYYY')
    }
  }
}

Usage in template - no parenthesis required

{{ someVar | formatUnix }}

This will take Unix epoch (timestamp) as input and give you back MM-DD-YYYY. I prefer filters to methods. If you haven’t written your own filters before, here are the docs

3reactions
savagemechaniccommented, Dec 1, 2017

@Joeper214 install moment for the filter not vue-moment. npm install --save moment

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unix Timestamp
The unix time stamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch...
Read more >
Epoch Converter - Unix Timestamp Converter
Easy epoch/Unix timestamp converter for computer programmers. Includes epoch explanation and conversion syntax in various programming languages.
Read more >
Unix time
Unix time is a date and time representation widely used in computing. It measures time by the number of seconds that have elapsed...
Read more >
Unix Timestamp - Epoch Converter - TimeStamp Converter
Convert epoch to human-readable date and vice versa. Enter a Timestamp Supports Unix timestamps in seconds, milliseconds, microseconds and nanoseconds. Convert ...
Read more >
Unix Timestamp Converter / Epoch Converter
An intuitive and powerful tool for converting Unix timestamps and human-readable times.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found