Have ideas to improve npm?Join in the discussion! »

    @idan-loo/date-formatter
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    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>

    Install

    npm i @idan-loo/date-formatter

    DownloadsWeekly Downloads

    18

    Version

    1.0.3

    License

    ISC

    Last publish

    Collaborators

    • avatar