Search Posts

Category: date

javascript return wrong first date and last dates

I found this code can be used to find the first date and the last date of a current month. var date = new Date(); var firstDay = new Date(date.getFullYear(), date.getMonth(), 1); var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0); Today is 11/1/2018 I used this piece of code for a calendar I am developing for one of my projects. Even though it should return first day of the month as 2018-01-01T18:30:00.000Z it returns […]

Angular 2 auto date-picker date in from

I would like to insert date-picker to my form which show me automaticlly today date without choosing date, the from what bellow is make you choose the date, any one can help me please with that.. <div class=”form-group”> <label class=”container” for=”name”>Erän saapumispäivä :</label> <div class=”col-sm-5″> <input type=”date” class=”form-control” id=”Entery_Date” [(ngModel)]=”addProduct.Entery_Date” name=”Entery_Date” #Entery_Date=”ngModel”> <div *ngIf=”Entery_Date.errors && (Entery_Date.dirty || Entery_Date.touched)” class=”alert alert-danger”> <div [hidden]=”!Entery_Date.errors.required”> Erän saapumispäivä on pakollinen! </div> </div> </div> Source: AngularJS

Date comparison validation in angular

I have 2 dates: 1.start and 2.end format is like this. 12/4/2017 console.log(startDate); 12/20/2017 console.log(endDate); I am writing a validation to check if the end date is bigger than start date throw error. this is what i have tried: var startDate = new Date(this.formB[‘startDateVal’]).toLocaleDateString(); var endDate=new Date(this.formB[‘dueDateVal’]).toLocaleDateString(); this is my condition: if(endDate<startDate){ this.bucketMsgClass=’fielderror’; this.bucketSuccessMsg = ‘End Date is must lower than Start Date.’; } where am i doing wrong.? Source: AngularJS

Highlight rows if date is more than some time in past with AngularJS ng-repeat

I have a small web app using Bootstrap & AngularJS to display table data received remotely via JSON api request. Table are generated with ng-repeat. On of the columns contains date of the last update named ‘last_seen’. I want to highlight rows where this field are more than 1 hour in past from the current date. Searching for examples here or on the web most suggests using Date() object or AngularJS ‘date’ filter. Based on […]

Subtraction of Date in angularjs

I want to subtract two dates in angularjs which are getting fetched from database. The code works fine for all values except subtraction between dates fetching from database…I used PHP with MySQL can anyone tell me how to do this subtraction. Here is the code. Thanx in advance <html> <head> <script src=”angular.js”></script> <script> var app= angular.module(“myapp”,[]); app.controller(“mycontroller”,function($scope,$http){ $http.get(“select.php”).success(function(response) { $scope.names =;}); }); </script> </head> <body ng-app=”myapp” ng-controller=”mycontroller”> <table border=1> <tr> <th>ID </th> <th>Name of […]

AngularJS Date string vs object error

I’m trying to retrieve a set of user information (by searching firstname) and it returns firstname and booking date (from mongoDB, mongoose schema uses date: Date). Firstname is type=text and booking date is type=date. It returns date as undefined and error message is Error: [ngModel:datefmt] Expected `2017-11-06T16:00:00.000Z to be a date. I read other questions/answers that it’s because type=date expects an object but the JSON is returning a string. I’m really new to Angular JS […]

Add date format into date regex

I am getting date format like this /Date(1495111091673)/.I have created one custom filter to change date format. app.filter(‘jsonDate’, function () { return function (date) { return new Date(date.match(/d+/)[0] * 1); } }) This filter returns date like this. Thu May 18 2017 18:08:11 GMT+0530 (India Standard Time) But I want it as standard format like dd/MM/yyyy so I have edited my filter code like this: app.filter(‘jsonDate’, function () { return function (date) { return new […]

How to filter Date format "2016-09-12 11:21:50 BRT" to format dd/MM/yyyy on Datatable or Angular Controller?

I need convert a date from back-end (JAVA) to front-end (Angular), the format date is “2016-09-12 11:21:50 BRT” or “2016-09-12 11:21:50 BRST”. I using a datatable javascript to populate a table on front-end. I need a filter for datatable or angular controller, I try used $filter of Angular, but did not work. Source: AngularJS

Allowing empty values in HTML5 date input

If I use an HTML5 date input and that field represents a date that maps to a nullable datetime column in the database, how do I get around setting an empty value in the input field? My application is using AngularJS and my ng-model is mapping to a scope variable with an initial value of null (or an empty string). Here’s what the browser’s console says: Error: [ngModel:datefmt] at angular.js:88 at Array.<anonymous> (angular.js:25308) at […]

Next Page »