16 Aug 2017

Ionic Get Current date [Get current date using Angularjs]

Show Full Date: (Method 1)

$scope.currDate = new Date();

alert($scope.currDate )

Output like this:
Wed Aug 16 2017 12:11:06 GMT+0530 (India Standard Time)



Show Full Date: (Method 2)

var date = new Date();

$scope.FromDate = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' +
date.getDate()).slice(-2);

Output like this:
2017-08-16


Get Current Date Only:
var date = new Date();

$cur_date = date.getDate();
alert($cur_date)

Get Current Month Only:
var date = new Date();
$cur_mon = date.getMonth() + 1;
alert($cur_mon)

Get Current Year:
var date = new Date();
$cur_year = date.getFullYear();
alert($cur_year)


No comments:

Post a Comment