$scope.date = new Date();
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
I have written something like this, and I know its not correct. Please correct me to display it in this format {{date | date:'EEE, dd MMM yyyy'}}
Edit 1: I want the tomorrow's date to be displayed on click of right arrow button and yesterday on left arrow button click at same position where Wed, Sept 3, 2014. Hide/show feature, how to code, I don't understand how to get it using angular. Reference image https://www.google.co.in/search?q=full+calendar+day+view&source=lnms&tbm=isch&sa=X&ei=PIqjVbP4FIijugS3qYOgBg&ved=0CAcQ_AUoAQ&biw=1360&bih=595#imgrc=2E7vtXzvWMYS0M%3A
Date object can be created in Angular component as seen below currentDate: Date = new Date(); // This creates an date object with current date date1: Date = new Date('01.01.2020'); // This creats an date object with given day month and year Let' declare angular component
To change the datetime format in angular we have to pass date time format parameter to the angular pipe as shown below. { { date_value | date :'short'}} // 6/15/19, 5:24 PM. The format ‘short’ is one of the predefined date formats in angular which converts our date value to ’M/d/yy, h:mm a’ format.
AngularJS date filter is used to convert a date into a specified format. When the date format is not specified, the default date format is ‘MMM d, yyyy’. Parameter Values: The date filter contains format and timezone parameters which is optional. “fullDate” – equivalent to “EEEE, MMMM d, y” (Tuesday, May 7, 2019)
Angular compare Date with current Date. Below is angular example to compare given date is before or after of an current date. We can use <,> !==,<=,>= relational operators for comparing dates
Probably you want something like this?
JSFiddle
HTML:
<div ng-app="myApp" ng-controller="myCtrl">
<p><a href="" ng-click="showToday = true; showTomorrow = false">Left arrow</a></p>
<p><a href="" ng-click="showTomorrow = true; showToday = false">Right arrow</a></p>
<span ng-show="showToday">Today: {{date | date:'EEE, dd MMM yyyy'}}</span>
<span ng-show="showTomorrow">Tomorrow: {{tomorrow | date:'EEE, dd MMM yyyy'}}</span>
</div>
JS:
angular.module('myApp', [])
.controller('myCtrl', function ($scope) {
$scope.showToday = false;
$scope.showTomorrow = false;
$scope.date = new Date();
$scope.tomorrow = new Date();
$scope.tomorrow.setDate($scope.tomorrow.getDate() + 1);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With