Introduction:
Here I will explain how to get previous day, month, year, time in AngularJS or get next day, month, year and time in AngularJS. By using “new Date()” function properties like setDate(), setMonth(), setFullYear() we can get current, previous and next day, month, time and year in AngularJS.
Description:
In previous articles I explained Angularjs uigrid show no records found, Angularjs Show Hide Div based on Checkbox selection, Angularjs Alert message on button click example, Angularjs convert number to currency format, Angularjs get dropdownlist selected value, Angularjs convert text to uppercase while typing and many articles relating to AngularJS, jQuery, JavaScript and asp.net. Now I will explain how to get previous or next day, month, year and time in AngularJS.
In previous articles I explained Angularjs uigrid show no records found, Angularjs Show Hide Div based on Checkbox selection, Angularjs Alert message on button click example, Angularjs convert number to currency format, Angularjs get dropdownlist selected value, Angularjs convert text to uppercase while typing and many articles relating to AngularJS, jQuery, JavaScript and asp.net. Now I will explain how to get previous or next day, month, year and time in AngularJS.
To get previous or next day, month, time and year
using AngularJS
we need to write the code like as shown below
|
If you want to check it in complete example you need to
write the code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Previous next Day,
Month, Year Month Time in Angularjs</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('sampleapp', [])
app.controller('samplecontrol', function ($scope) {
var previousDate = new Date()
previousDate.setDate(previousDate.getDate() - 1)
var nextDate = new Date()
nextDate.setDate(nextDate.getDate() + 1)
var previousMonth = new Date()
previousMonth.setMonth(previousMonth.getMonth() - 1);
var nextMonth = new Date()
nextMonth.setMonth(nextMonth.getMonth() + 1);
var year = new Date()
year.setFullYear(year.getFullYear())
$scope.cdate = new Date();
$scope.pday = previousDate;
$scope.nday = nextDate;
$scope.pmonth = previousMonth;
$scope.nmonth = nextMonth;
$scope.cyear = year;
});
</script>
</head>
<body data-ng-app="sampleapp"
data-ng-controller="samplecontrol">
<form id="form1">
<div>
Current Date:<b> {{cdate |
date:'dd/MM/yyyy hh:mm:ss a'}}</b><br />
Previous Day:<b> {{pday |
date:'dd'}}</b><br />
Next Day:<b> {{nday |
date:'dd'}}</b><br />
Previous Month:<b> {{pmonth |
date:'MM'}}</b><br />
Next Month:<b> {{nmonth |
date:'MM'}}</b><br />
Current Year :<b>{{cyear |
date:'yyyy'}}</b><br />
</div>
</form>
</body>
</html>
|
Live
Demo
For
live demo check below dates
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
1 comments :
Its very helpfull
Note: Only a member of this blog may post a comment.