angular-moment

How to set today date and time as default in angular-moment-picker

浪尽此生 提交于 2019-12-08 04:05:22
问题 I am using angular-moment-picker input for datetimepicker, and I want to set today date and current time on the input. Here is my source code. can you please help me. Thank you <input class="form-control" format="DD/MM/YYYY HH:mm" ng-model-options="{ updateOn: 'blur' }" moment-picker="startDate" id="startDate" ng-model="startDate"> 回答1: set default value startDate when controller initialized angular .module('Demo', ['moment-picker']) .controller('DemoController', ['$scope', function ($scope)

Check if the input day is Monday with moment.js

泄露秘密 提交于 2019-12-07 07:22:35
问题 Well, I want to check if a day of date is Monday like: $scope.myDate = new Date(); moment($scope.myDate, 'DD-MM-YYYY').dayIs('monday') In Chile - my country - the first day of week is Monday, so, really I want check if the input date is begin of week. I try using moment($scope.myDate, 'DD-MM-YYYY').startOf('isoweek') but, this don't work for me. 回答1: According to the documentation - Moment.js has a locale setting which should solve this for you; Day of Week (Locale Aware) 2.1.0+ moment()

Check if the input day is Monday with moment.js

北城以北 提交于 2019-12-05 15:12:36
Well, I want to check if a day of date is Monday like: $scope.myDate = new Date(); moment($scope.myDate, 'DD-MM-YYYY').dayIs('monday') In Chile - my country - the first day of week is Monday, so, really I want check if the input date is begin of week. I try using moment($scope.myDate, 'DD-MM-YYYY').startOf('isoweek') but, this don't work for me. According to the documentation - Moment.js has a locale setting which should solve this for you; Day of Week (Locale Aware) 2.1.0+ moment().weekday(Number); moment().weekday(); // Number Gets or sets the day of the week according to the locale. If the

Get timezone from users browser using moment(timezone).js

别等时光非礼了梦想. 提交于 2019-12-03 04:43:13
问题 What is the best way to get client's timezone and convert it to some other timezone when using moment.js and moment-timezone.js I want to find out what is clients timezone and later convert his date and time into some other timezone. Does anybody has experience with this? 回答1: var timedifference = new Date().getTimezoneOffset(); This returns the difference from the clients timezone from UTC time. You can then play around with it as you like. 回答2: When using moment.js, use: var tz = moment.tz

Angular Moment : Moment Timezone has no data for America/New_York

末鹿安然 提交于 2019-12-01 15:08:00
Date received from server is in UTC timezone and I need to convert it to a particular timezone, for example : America/New_York .Following is the code for same <span class="bold" ng-bind="sess.date_time | amTimezone:'America/New_York' | amDateFormat:'h:mm a'"></span> But on doing so I get the following error: Moment Timezone has no data for America/New_York. See http://momentjs.com/timezone/docs/#/data-loading/. But America/New_York is a known timezone to moment but still it is asking me to add the Timezone. You need to load all of the following: moment moment-timezone time zone data for moment

Moment.js amDateFormat always returning date from 1970

半城伤御伤魂 提交于 2019-12-01 05:34:58
http://plnkr.co/edit/5zxXEEz30t51yGhgYWVF?p=preview I'm using Moment.js and Angular-moment in my app. For some reason it's converting all my epoch timestamps to the same date from 1970. <td class="timespan">{{tag.added_epoch | amDateFormat:'dddd, MMMM Do YYYY'}}</td> This is what the tag.added_epoch value is added_epoch: 1432252800 However when I convert it online, I get the correct date: Any idea why my filter is turning 1432252800 into Saturday, January 17th 1970 ? I'm just quickly summarizing the problem and solution. Moment.js offers two different ways to create a date from a unix

How to Include moment-timezone in Angular 2 App

感情迁移 提交于 2019-11-30 11:31:10
I realize, this question is repeated but previous once does not provide apt answer moment package was already installed 1.Installed package npm install moment-timezone --save Inside node_modules directory | |--moment |--moment-timezone directories present 2. Index.html included script <script src="node_modules/moment-timezone/moment-timezone.js"></script> System.config.js var map = { 'moment': 'node_modules/moment', 'momentzone': 'node_modules/moment-timezone' }; var packages = { 'moment': { defaultExtension: 'js' }, 'momentzone': { defaultExtension: 'js' } }; 3.Inside component.ts file import

How to format 'angular-moment's 'am-time-ago' directive?

不想你离开。 提交于 2019-11-30 09:20:39
LIVE DEMO I use the am-time-ago directive to show a relative timestamp: <span am-time-ago="publishedAt"></span> By default, it is formatted as "a day ago", "5 days ago", etc. How could I change the formatting to be "1d", "5d", "3h", etc? Nix You could customize humanize, somewhere in your config or app start. moment.lang('en', { relativeTime : { future: "in %s", past: "%s ago", s: "%d seconds", m: "1m", mm: "%dm", h: "1h", hh: "%dh", d: "1d", dd: "%dd", M: "1m", MM: "%dm", y: "1y", yy: "%dy" } }); x = new moment(); z = x.clone().add('hours',1); x.from(z, false); >> 1h ago x.from(z, true) //no

How to format 'angular-moment's 'am-time-ago' directive?

落花浮王杯 提交于 2019-11-29 14:09:25
问题 LIVE DEMO I use the am-time-ago directive to show a relative timestamp: <span am-time-ago="publishedAt"></span> By default, it is formatted as "a day ago", "5 days ago", etc. How could I change the formatting to be "1d", "5d", "3h", etc? 回答1: You could customize humanize, somewhere in your config or app start. moment.lang('en', { relativeTime : { future: "in %s", past: "%s ago", s: "%d seconds", m: "1m", mm: "%dm", h: "1h", hh: "%dh", d: "1d", dd: "%dd", M: "1m", MM: "%dm", y: "1y", yy: "%dy"

How to Include moment-timezone in Angular 2 App

我只是一个虾纸丫 提交于 2019-11-29 12:00:50
问题 I realize, this question is repeated but previous once does not provide apt answer moment package was already installed 1.Installed package npm install moment-timezone --save Inside node_modules directory | |--moment |--moment-timezone directories present 2. Index.html included script <script src="node_modules/moment-timezone/moment-timezone.js"></script> System.config.js var map = { 'moment': 'node_modules/moment', 'momentzone': 'node_modules/moment-timezone' }; var packages = { 'moment': {