Skip to content
Advertisement

Tag: momentjs

Moment.js always returns ‘a few seconds ago’

From the docs: “To get the current date and time, just call moment() with no parameters. This is essentially the same as calling moment(new Date()). Note: From version 2.14.0, moment([]) and moment({}) also return now. They used to default to start-of-today before 2.14.0, but that was arbitrary so it was changed.” I have tried both and also and a lot

Adding minutes to datetime in momentjs

I need to add the variable secondsToMinutes to the startdate. secondsToMinutes is “3:20” startDate = “2:00 PM” endDate should equal “2:03:20 PM”. I’ve tried a number of ways and get errors each and every time. Date shows up as invalid date. Answer moment().format(“LTS”) returns a string value in hh:mm:ss AM/PM format. When you create a moment object using a string

Using moment to format time in relation to now

I’m trying to display a date like “a few seconds ago”, “10 minutes ago”, “a day ago” with momentjs in the browser. date returns “in 14 minutes” NOT “14 minutes ago”. How can I fix this? Answer Because you would have been comparing it in that way only. Now should be less than the date to show ago. Current Date

How to compare two Moment.js Objects

I have an Array with Moment.js objects in a variable: And a function to determinate if a value is in this array: But even if i pass a moment object, as checkFeriado(moment(“2016-01-01”)); i’m getting false. Whats wrong with my code? Is there a best way to do this? Entire project have jQuery and Moment.js Answer Javascript objects cannot be compared

Deprecation warning in Moment.js – Not in a recognized ISO format

I’m getting a warning that a value provided to moment is not in a recognized ISO format. I changed my variable today with the moment function and still it doesn’t work. Here’s the warning error: Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers

Moment.js compare two date thrown a warning

I have created a simple app, which need a date comparison. I used Moment.js, and I have tried on answer on this question: Compare two dates in JS Moment js date time comparison How to compare only date in moment.js But all of them not working for me. and now I use this code: But in the console it’s thrown

How to parse given date string using moment.js?

I want the following date string to be formatted using moment.js but it gives invalid date. How to parse it correctly or is there any other way to do so? Answer Just use pattern as second parameter in moment function more here in the docs: http://momentjs.com/docs/#/parsing/string-format/

Advertisement