Datepicker

hi,
How to set the default date of ion-datetime is current month 1st date Ionic-v3 .
Thanks for reading!

Hi,
I thing that for this is the best way to use moment.js. With momentjs you can check actual month and then set [(ngModel)] value for ion-datetime.

Hope that this will help you :wink:

Hi, @nadapana

Try this:

Add this code in templet file

<ion-item>
  <ion-label>Date</ion-label>
  <ion-datetime displayFormat="DD.MM.YY" [(ngModel)]="defalutDate"></ion-datetime>
</ion-item>

Add this code in component file

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

      defalutDate:any;

      constructor(public navCtrl: NavController){
         let currentDate  = new Date();
         this.defalutDate = currentDate.getFullYear()+'-'+("0" + (currentDate.getMonth() + 1)).slice(-2)+'-'+'01';     
      }
}

Thank you

Thanks. for your replay.

i am new to ionic . you saved my time

that worked for me.

if your issue was resolved, Please mark as a solution.