How to get a date object with tomorrow's date and specific time in UTC using MomentJS?
how to get tomorrow date in angular 6
get tomorrow date java
get tomorrow date = moment js
get tomorrow date php
date js get next day
I'm trying to get a date object with tomorrow's date, at 08:00:00 AM. I tried this, but it just returns tomorrow's date, but at the local 08:00AM time and not in UTC.
var tomorrow = moment(new Date()).add(1,'days'); tomorrow.set('hour', 8); tomorrow.set('minute', 0); tomorrow.set('second', 0);
Is there a way to get that datetime object in UTC?
You just need to call
.utc() function of that object.
var tomorrow = moment(new Date()).add(1,'days'); tomorrow.set('hour', 8); tomorrow.set('minute', 0); tomorrow.set('second', 0); console.log(tomorrow.utc());
There's no need to use
var d = new Date(); var now_utc = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate() + 1, 8, 0, 0); console.log(new Date(now_utc));
You can do this easily enough in moment.js:
var timeUtc = moment.utc().startOf('day').add(1, 'days').add(8, 'hours'); console.log("Output time: ", timeUtc.toISOString());
How to get previous and next day's dates in android?, Use the new Date() constructor to create a date instance of today. Then, retrieving the day of tomorrow is a calculation of adding one day to the current day of the month using. You can retrieve the day of “today” using the . getDate() method. Not counting all the boilerplate code and comments, you can get tomorrow's date in four lines of code, or fewer. Here's the source code for our class that shows how to get "tomorrow" by adding one day to today: import java.util.*; /** * A Java Date and Calendar example that shows how to * get tomorrow's date (i.e., the next day).
- Thank you for providing this alternative, I appreciate it!