In this example, I will you show how to get the current date and time in the angular js we will learn how to make this and how to use the angular application with a specific date format. you can use date format like yyyy-mm-dd, dd/mm/yyyy, mm-dd-yyyy hh:mm:ss and many more formats you can use as per your need. Now we will make this example using angular js ng-bind directive.
So, now you can follow bellow simple we are getting time and date from the date object in this example. So, You can see the example and make it.
Syntax:
{{ 'Date Object' | date: 'Date Format' }}
{{ CurrentDate | date: 'dd/MM/yyyy' }}
Example : index.html
<!doctype html>
<html>
<head>
<title>How to get Current Date and Time in AngularJS? - webappfix.com</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body ng-app="MyApp">
<div ng-controller="AppCtrl">
<p>{{ CurrentDate | date:'MM/dd/yyyy'}}</p>
<p>{{ CurrentDate | date:'dd/MM/yyyy'}}</p>
<p>{{ CurrentDate | date:'dd/MM/yyyy HH:mm:ss'}}</p>
</div>
</body>
<script type="text/javascript">
var app = angular.module('MyApp', []);
app.controller('AppCtrl', ['$scope', '$http', function($scope, $http) {
$scope.CurrentDate = new Date();
console.log($scope.CurrentDate);
}]);
</script>
</html>
I hope you like this article.
Thanks...
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Vuejs form input binding with radio checkbox
- How to Add Bootstrap in Angular 8 | Install Bootstrap 4 in Angular 8
- Laravel 9 Ajax Login Form Submit With Validation Handled
- AngularJS Login Logout with Laravel 6
- Select2 ajax example
- Keep array input value from localstorage on page refresh
- PHP Laravel JQuery Form Validation Example
- JQuery - Add Edit & Delete HTML Table Row Example
- Uncaught ReferenceError: $ is not defined jQuery - Javascript
- Send WhatsApp Messages Using Chat API In jQuery - Ajax