npm.io
0.0.9 • Published 3 years ago

ngx-round-date

Licence
MIT
Version
0.0.9
Deps
1
Size
19 kB
Vulns
0
Weekly
0

ngx-round-date

npm version npm downloads

Simple round-date pipe

  • Compatible with Angular version 12.2.0

Example

Code:

this.testDate=new Date(2022,12,31,23,59,59);

Template:

<span>{{testDate | roundDate}}</span> 

It displays:

01/02/2023 00:00:00

Usage

  1. Install ngx-round-date through npm package manager using the following command:

    npm i ngx-round-date --save
  2. Add RoundDatePipeModule into your AppModule class. app.module.ts would look like this:

    import {NgModule} from '@angular/core';
    import {BrowserModule} from '@angular/platform-browser';
    import {AppComponent} from './app.component';
    import { RoundDatePipeModule } from 'ngx-round-date';
    
    @NgModule({
      imports: [BrowserModule, RoundDatePipeModule],
      declarations: [AppComponent],
      bootstrap: [AppComponent],
    })
    export class AppModule {
    }
  3. Add the pipe into html (default round 5 minutes)

    <span>{{testDate | roundDate}}</span>

    or

    <span>{{testDate | roundDate:10}}</span>
License

The MIT License (see the LICENSE file for the full text)