1.0.3 • Published 7 years ago

@idan-loo/date-formatter v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 years ago

date-formatter

Intro

A date formatter. Can use as vue filter.

Install

npm install --save @idan-loo/date-formatter

Example

import dateFormatter from '@idan-loo/date-formatter';

const date = new Date();
const fmt = 'yyyy-MM-dd hh:mm:ss';

// result => '2017-08-06 14:35'
// fmt will be 'yyyy-MM-dd hh:mm:ss if you don't assign value explicitly
const result = dateFormatter.format(date, fmt);

Example as vue filter

<template>
  <div>{{ date | dateFormat }}</div>
  <div>{{ date | dateFormat('yyyy-MM-dd') }}
</template>

<script>
import dateFormatter from '@idan-loo/date-formatter';
export default {
  data() {
    return {
      date: new Date()
    }
  },
  filter: {
    dateFormat: dateFormatter.format
  }
}
<script>