AngularJs Get Previous Day

AngularJs Get Previous, Day Next, Day Month, Year, Month, Time

How to get Previous Day, Next Day, Month, Year Month Time using AngularJs?

Hello everyone, I am going to share the code-sample for Get  the Previous Day, Next Day, Month, Year, Month Time etc.


The Table of content as given below

1.       The AngularJs code sample
2.       The HTML code sample
3.       The Full Live demo code
4.       The OutPut link

The AngularJs code sample

        var app = angular.module('dayApp', []);

        app.controller('dayCtrl', function ($scope) {
            $scope.today = new Date();
            $scope.preday = new Date().getDate() - 1;
            $scope.nextday = new Date().getDate() + 1;
            $scope.premonth = new Date().getMonth() - 1;
            $scope.nextmonth = new Date().getMonth() + 1;
            $scope.curentyear = new Date().getFullYear();
        });

The HTML code sample

<div ng-app="dayApp">
    <h4>Angularjs Get Previous Day, next Day, Month, Year Month Time </h4>
    <div ng-controller="dayCtrl">
        <p class="col">Current Date: {{today | date :'dd-MM-yyyy'}}</p>
        <p class="col"> Previous Day: {{preday}}</p>
        <p class="col"> Next Day: {{nextday }}</p>
        <p class="col"> Previous Month: {{premonth }}</p>
        <p class="col"> Next Month:{{nextmonth}}</p>
        <p class="col"> Current Year :{{curentyear }}</p>
    </div>
</div>

The Full Live demo code

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Angularjs Get Previous Day, next Day, Month, Year Month Time</title>
    <link rel="stylesheet" href="style.css" />
    <script src="https://code.angularjs.org/1.4.1/angular.js"></script>
    <script>
        var app = angular.module('dayApp', [])
        app.controller('dayCtrl', function ($scope) {
            $scope.today = new Date();
            $scope.preday = new Date().getDate() - 1;
            $scope.nextday = new Date().getDate() + 1;
            $scope.premonth = new Date().getMonth() - 1;
            $scope.nextmonth = new Date().getMonth() + 1;
            $scope.curentyear = new Date().getFullYear();
        });
    </script>
</head>

<body ng-app="dayApp">
    <h4>Angularjs Get Previous Day, next Day, Month, Year Month Time </h4>
    <div ng-controller="dayCtrl">
        <p class="col">Current Date: {{today | date :'dd-MM-yyyy'}}</p>
        <p class="col"> Previous Day: {{preday}}</p>
        <p class="col"> Next Day: {{nextday }}</p>
        <p class="col"> Previous Month: {{premonth }}</p>
        <p class="col"> Next Month:{{nextmonth}}</p>
        <p class="col"> Current Year :{{curentyear }}</p>
    </div>
</body>

</html>


The Output: go to link http://embed.plnkr.co/to7wqz/preview


ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Buy Books Online at Best Prices

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.