How to use the utc function from moment-timezone
Find comprehensive JavaScript moment-timezone.utc code examples handpicked from public code repositorys.
moment-timezone.utc is a function in Moment.js that returns the current time in Coordinated Universal Time (UTC) timezone.
272 273 274 275 276 277 278 279 280 281 282
// Generic timestamp formatter const formatTimeStamp = (dateStr, format) => { const date = new Date(dateStr); // moment format is passed. format accordingly if (format) { return moment.utc(date).format(format); } // return default format return date.getTime();
+ 4 other calls in file
How does moment-timezone.utc work?
moment-timezone
is a library that allows handling and manipulation of dates and times with respect to different time zones. The moment-timezone.utc()
function returns a Moment
object representing the current date and time in the UTC time zone.
GitHub: mbmccormick/fitminder
48 49 50 51 52 53 54 55 56 57
else return 'never'; } app.locals.utc = function () { return moment.utc(); } app.locals.add = function (date, amount, unit) { return moment(date).add(amount, unit);
+ 9 other calls in file
GitHub: icanbwell/fhir-server
225 226 227 228 229 230 231 232 233 234
); /** * @type {string} */ const currentDate = moment.utc().format('YYYY-MM-DD'); // noinspection JSCheckFunctionSignatures try { let {/** @type {string} */ base_version} = parsedArgs;
Ai Example
1 2 3 4
const moment = require("moment-timezone"); const now = moment.utc(); console.log(now.format()); // prints the current date and time in UTC
In this example, we first require the moment-timezone module and create a new moment object using the moment.utc() function, which creates a moment object representing the current date and time in UTC. We then use the format() function to print the date and time in the default format.
GitHub: webreinvent/vaahvue
569 570 571 572 573 574 575 576 577 578
formatTimeUTC: function (value, format='HH:mm') { if(!value) { return ""; } return moment.utc(value).format(format); }, //--------------------------------------------------------------------- formatDateTimeUTC: function (value) { if(!value)
+ 2 other calls in file
GitHub: mindset-tk/brobot
94 95 96 97 98 99 100 101 102 103
* Perform a single run of the checks for pending scheduled tasks. * * @returns {Promise<void>} Resolves when the work for this tick is finished. */ async tick() { const now = moment.utc(); const votesByGuild = Object.entries(this.ongoingVotes); for (const [guild, votes] of votesByGuild) { const endingVotes = votes.filter((vote) => vote.due.isSameOrBefore(now));
318 319 320 321 322 323 324 325 326 327
}); it('Can reply to your own comment', async function () { // Should not update last_seen_at or last_commented_at when both are already set to a value on the same day const timezone = settingsCache.get('timezone'); const date = moment.utc(new Date()).tz(timezone).startOf('day').toDate(); await models.Member.edit({last_seen_at: date, last_commented_at: date}, {id: member.get('id')}); await membersAgent .post(`/api/comments/`)
+ 8 other calls in file
40 41 42 43 44 45 46 47 48 49 50 51 52
// Obtener bitacora exports.getRecord = async (socialEmployee = undefined) => { const dateStart = moment(moment.tz('America/Bogota')).add(-1, 'd').startOf('day').utc().format('YYYY-MM-DD HH:mm:ss'); const dateEnd = moment.utc(moment.tz('America/Bogota')).format(); }; // update service async function updateService(serviceId, setChanges) {
+ 3 other calls in file
GitHub: tokarik1312/webtech-app
86 87 88 89 90 91 92 93 94 95
onSave() { if (this.props.conditionToChange === false) { this.props.editPublishedEvent(this.props.publishedEvent.id, { text: this.state.text, date: moment.utc().format() }) } else { this.props.editUnpublishedEvent(this.props.unpublishedEvent.id, { text: this.state.text,
GitHub: transloadit/uppy
52 53 54 55 56 57 58 59 60 61
const user = await client.get('users/me', { responseType: 'json' }).json() const { timezone } = user if (!from && !to && !meetingId) { const end = cursor && moment.utc(cursor).endOf('day').tz(timezone || 'UTC') return initializeData(user, end) } if (from && to) {
+ 5 other calls in file
moment-timezone.tz is the most popular function in moment-timezone (1000 examples)