Search Posts

Category: date

Date loses format and goes to undefined

I created this code. var selectedDate = new Date(); selectedDate = new Date(measure.date + ” ” + measure.column[key].time); console.log(measure.date + ” ” + measure.column[key].time); //08/05/2017 08:05 <- dd/MM/yyyy HH:mm console.log(selectedDate); //Sat Aug 05 2017 08:05:00 GMT+0200 (Romance Summer Time) $scope.popupData.push({selectedHour: selectedDate, minHour:$scope.minvalueHour, maxHour:$scope.maxvalueHour, valueItem:measure.column[key].value}); console.log($scope.popupData[key].selectedHour); //0: {selectedHour: undefined, minHour: “08:00”, maxHour: “08:59”, valueItem: “10”, $$hashKey: “object:887”}length: 1__proto__: Array(0) This code has two problems, the first, it changes the months for the days and the second […]

given a timezone string, how can i set a date object to that TZ in JS

I have this code: toolFilters.filter(‘dateAccordingToTimeZone’, function($filter) { // Gets the number of milliseconds pass from 1970 and convert it to time according to given timezone, currently // supported “Asia/Jerusalem” and “America/Los_Angeles” return function(milliSeconds, timeZoneId) { if (milliSeconds == 0) { return “”; } var d = new Date(); var n = d.getTimezoneOffset(); if ((timeZoneId == “Asia/Jerusalem”) || (timeZoneId == “IL”)) { return $filter(‘date’)(milliSeconds, ‘MMM d, y H:mm:ss’, ‘+0200’); } else if ((timeZoneId == “America/Los_Angeles”)) { […]

Datepicker value is NaN when used in Date.parse

I’m using basic bootstrap datepicker… <div class=”input-group date” data-provide=”datepicker”> <input type=”text” class=”form-control” name=”startDate” id=”startDate” value=”20/01/2016″> <div class=”input-group-addon”> <span class=”glyphicon glyphicon-th”></span> </div> </div> $.fn.datepicker.defaults.format = “dd/mm/yyyy”; $(‘.datepicker’).datepicker({ startDate: ‘-3d’ }); In my App.js I have a filter for filtering a JSON object list (this filter works if I hard code dates in the IF such as “> ’01/01/2016′”). I’m struggling to get the value the user selects in the datepicker. //Filter: Dates WIP App.filter(‘dateRange’, function () […]

angularjs – confusion with date formats

I am super confused with date formats and need some clarifications. I am trying to pre-populate a form with a date and have set $scope.selectedDate = c.data.Appt.enrolled.start_date; In my console, c.data.Appt.enrolled.start_date is a string: However, when I set $scope.selectedDate to that, nothing shows up. Conversely, if I add new Date in front (new Date(c.data.Appt.enrolled.start_date)) a date shows up, but it is one day before (April 24, 2018). In addition to that, when I try to […]

Angularjs show all date in separate div after select month

in Angularjs i used moth and year picker below script <!DOCTYPE html> <html ng-app=”Demo” style=”height:100%;”> <head> <meta charset=”utf-8″> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <title>Angular Moment Picker</title> <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css” rel=”stylesheet”> <link href=”//rawgit.com/indrimuska/angular-moment-picker/master/dist/angular-moment-picker.css” rel=”stylesheet”> </head> <body ng-cloak style=”padding:20px;” ng-controller=”DemoController as ctrl”> <input class=”form-control” placeholder=”Select a date…” moment-picker=”ctrl.stringDate” format=”YYYY-MM” set-on-select=”true” ng-model=”ctrl.momentDate” ng-model-options=”{ updateOn: ‘blur’ }”> <script src=”https//maxcdn.bootstrapcdn.com//ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js”></script> <script src=”https//maxcdn.bootstrapcdn.com//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment-with-locales.js”></script> <script src=”https//maxcdn.bootstrapcdn.com//rawgit.com/indrimuska/angular-moment-picker/master/dist/angular-moment-picker.js”></script> <script src=”script.js”></script> </body> </html> it’s working fine but i need after select show all date […]

Datepicker Popup (ui.bootstrap.datepickerPopup) Error format date

I’m trying to use Datepicker Popup (angularjs 1.6.6), from angular ui I’ve use the example Plunker. All works perfectly but in my project the result is this: I’ve had checked the follogin things: The files that reference to the .js. Example: <script src=”https//angular-ui.github.io//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js”></script> <script src=”https//angular-ui.github.io//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js”></script> <script src=”https//angular-ui.github.io//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js”></script> <script src=”https//angular-ui.github.io//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js”></script> My proyect: <script src=”bower_components/angular/angular.js”></script> <script src=”bower_components/angular-animate/angular-animate.js”></script> <script src=”bower_components/angular-sanitize/angular-sanitize.js”></script> <script src=”bower_components/angular-bootstrap/ui-bootstrap-tpls.js”></script> The style css, maybe here is the problem, but I’m not sure: Example: <link href=”//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css” rel=”stylesheet”> […]

Date format when editing a record retrieved from db using an HTML5 input type=date [duplicate]

This question already has an answer here: Converting string to date in js 27 answers I have a list of records with a button next to it that when you click on it, it opens a form with data retrieved from the database for that record. The API sends a JSON object retrieved from the database with a simple SELECT * FROM… The problem I have is that I can’t get the date to be […]

Date format that Excel [duplicate]

This question already has an answer here: Converting Excel Date Serial Number to Date using Javascript 3 answers I’m having trouble using js-xlsx, to transform into JSON trying to format date with JavaScript (js.xlsx) But the format returned is 41852.916666667 where I could not identify the format. Make read file with directive : $elm.on(‘change’, function (e) { var files = e.target.files,file; if (!files || files.length == 0) return; file = files[0]; var fileReader = new […]

Month and year wise display date in descending order

In My monogdb I have Date column. I want to display the date in descending order with month and year wise. Date column: 14-03-2018 12-03-2018 13-03-2018 11-03-2018 10-02-2018 06-01-2018 09-01-2018 08-02-2018 07-01-2017 Expected result: 14-03-2018 13-03-2018 12-03-2018 11-03-2018 10-02-2018 08-02-2018 09-01-2018 07-01-2017 I used tr dir-paginate date on dates orderBy:’LastFollowupDate’:’desc’” but is displaying what I expect How to achieve this in angularjs Source: AngularJS

AngularJs filter date adding 2 hours

how to AngularJs filter date adding 2 hours I have a reservation calendar, where I can click on day and time, so I open a bootstrap modal where there is a date input and a time input. I’m using on the modal load with “date” parameter: $scope.calendarChosenDay = $filter(‘date’)(new Date(date), ‘yyyy-MM-dd’); $scope.calendarChosenTime = $filter(‘date’)(new Date(date), ‘HH:mm’); When the modal opens, the date is correct, but the time is adding 2 hours because of timezone i […]

Next Page »