Search Posts

Category: momentjs

making "angularJS" scheduler from my calendar

I have an “AngularJS” calendar that I made using a guide online and modified it a little and I want to convert it to a scheduler. What I want is that when user double-click on a day a modal opens (that I used bootstrap 3 modal for that) and when the user filled the form and clicked on save it should put the input value in some kind of object and show it in the […]

Html5 date field not able to set back to date field coming from backend

i have html Date field. i have a create page where i am inserting date to MySQL db i have a edit page where i am fetching the date and set back to input field. <input id=”dob” name=”dob” type=”date” placeholder=”Enter date of birth” class=”form-control” ng-model=”user.dob”/> JS function loadUserById() { ApiService.getById($scope.id).then(function(response) { $scope.user = response.data[0]; $scope.user.password1 = response.data[0].password; if($scope.user.dob) { var date = new Date($scope.user.dob); $scope.user.dob = moment(date).format(“MM/DD/YYYY”); } }, function(error) { console.log(error); }); } Problem […]

MomentJS rounding up seconds to minute – AngularJS

I have a time picker, where the user inputs a period of time expressed in decimal (8.5 for example for 8h30min), but he can also input manually “from” and “to” periods, so for example -> from: 08:00, to: 17:30 and the data that will pass is always in decimal, 8.5 in this case. Then I have a function that converts that decimal in time and shows it as string somewhere. The problem is that the […]

charts.js tooltips on different data ranges

I’m using charts.js (with angular-charts directive), and I’m facing a problem with different dataset sizez. I have to display in a line-chart some values in a timeline. So my data is structured like this : datasets : [ [ {“x” : date1, “y” : 2 }, {“x” : date1, “y” : 5 } ..], //first dataset [ {“x” : date2, “y” : 3 }, {“x” : date4, “y” : 7 } ..] //second one ]; […]

AngularJS changing date with momentJS by a range of 6months

I have a date picker where and a table, showing months from January to December, and the user can switch from year to year and show data for that year in the table. Now I wanted to change this to a new picker: By default, I’ll be showing like now the current year when the user opens the app. But when you click the forward arrow in the date picker, it’s not gonna switch by […]

How to set locale for angularjs-bootstrap-datetimepicker via imported momentjs

I use angularjs-bootstrap-datetimepicker as import uiBootsrapDatetimepicker from ‘angularjs-bootstrap-datetimepicker’; angula.module(‘myModule’, [uiBootsrapDatetimepicker]) and Webpack for bundling. I want to set a custom locale (or how to change a first day of the week?) and I found in readme: All internationalization is handled by Moment.js, see Moment’s documentation for details. In most cases, all that is needed is a call to moment.locale(String) But how if there is import new momentjs instance in code (GitHub url): var mt = […]

momentjs time comparison with timezone

I am trying to compare two times: Time A : A datetime which I know is in ‘America/Chicago’ timezone Time B : A datetime for current time which I want to convert to ‘America/Chicago’ and compare to Time A. I am doing this simple test and unable to understand why all the below give the same result: moment(’05/31/2018 03:25:00′).tz(‘America/Chicago’).diff(moment().tz(‘America/Phoenix’), ‘minutes’) Result: 111 moment(’05/31/2018 03:25:00′).tz(‘America/Chicago’).diff(moment().tz(‘America/Los_Angeles’), ‘minutes’) Result: 110 moment(’05/31/2018 03:25:00′).tz(‘America/Chicago’).diff(moment().tz(‘America/Chicago’), ‘minutes’) Result: 110 moment(’05/31/2018 03:25:00′).diff(moment().tz(‘America/Chicago’), ‘minutes’) […]

ChartJS: Translate x axis month to other languages

I’m having difficulties in finding out how to translate the time axis. I’m using ‘MMM YYYY’ for time displayFormats in xAxes. So it always displays date like “May 2018”. Does anyone know how to localize here? For example, if the language is french, the month should be displayed as Mai instead of May. I searched everywhere, only find someone said it is possible to do that using time.parser, but I am not sure how to […]

Including Moment.js in agular 1 project [duplicate]

This question already has an answer here: how to get full momentjs api inside angular view? 2 answers Earlier i had worked with moment.js in a project and now i need to use it with another project.I need to use this library in an angular 1 controller. I have included the same from a CDN but if i try to inject it into my controller it gives me weird errors. <script src=”https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js”></script> The above line […]

AngularJS : use momentJS in html

I want to use momentJS to convert a datetime variable coming from api from utc to local, when I use the function .local() in JS part I got several problem so I want to ask if it’s possible to use moment in html side ! .directive-report-images{ ng_show: ‘conditionIsChecked && fragment._parentConditionChecked’ } .row .col-md-4 .title %h5.black {{ fragment.title }} .col-md-8 %report_fragment_visibility .row{ ng_if: ‘fragment.media().length <= 2’ } .col-md-6.thumbnail{ ng_repeat: “img in fragment.media() | notArchived | orderBy:’order'” […]

Next Page »