Minutes since midnight in Momentjs

// Your moment var mmt = moment(); // Your moment at midnight var mmtMidnight = mmt.clone().startOf(‘day’); // Difference in minutes var diffMinutes = mmt.diff(mmtMidnight, ‘minutes’); By default, moment#diff will return number rounded down. If you want the floating point number, pass true as the third argument. Before 2.0.0, moment#diff returned rounded number, not a rounded … Read more

With momentjs, how do I tell if 2 moments represent the same day (not, necessarily, the same time)?

You can use both ‘day’ and ‘date’ to isSame. As the docs says: Check if a moment is the same as another moment. When including a second parameter, it will match all units equal or larger. Passing in month will check month and year. Passing in day will check day, month, and year. Like moment#isAfter … Read more

Get the days, hours and minutes in Moment.js

MomentJS can calculate all that for you without you doing any logic. First find the difference between the two moments Express it as a Duration Then display whichever component .days(), .hours() of the duration that you want. Note: You can also express the entire duration .asDays(), .asHours() etc if you want. const now = moment(“2017-01-26T14:21:22+0000”); … Read more

Same date in different time zone

Here’s how you could do what you are asking: // get a moment representing the current time var now = moment(); // create a new moment based on the original one var another = now.clone(); // change the offset of the new moment – passing true to keep the local time another.utcOffset(‘+05:30’, true); // log … Read more

get next week start and end using jquery and moment js

A little late to the party but here is the simplest way I’ve found to express starts/ends of weeks. The isoWeek argument starts weeks on Monday according to the ISO 8601, while week starts weeks depending on your locale (so probably either Sunday or Monday). This week: moment().startOf(‘isoWeek’) moment().endOf(‘isoWeek’) Next week: moment().add(1, ‘weeks’).startOf(‘isoWeek’) moment().add(1, ‘weeks’).endOf(‘isoWeek’) … Read more

Updating time offset with moment().utcOffset()

The main issue is that you are passing the offset as a string instead of a number. moment.utc(“2015-10-01 01:24:21”).utcOffset(“-240”).format(‘YYYYMMDD HHmmss ZZ’) // “20151001 012421 +0000” moment.utc(“2015-10-01 01:24:21”).utcOffset(-240).format(‘YYYYMMDD HHmmss ZZ’) // “20150930 212421 -0400” When you have an offset in terms of minutes, then you must use the numeric form. You can always convert it: moment.utc(“2015-10-01 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)