python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
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

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions