Is there a way to use javascript to take a non-UTC date, add 1 UTC day to it, reset the time to zero, and then convert it to an ISO string?
new Date().toISOString()
2017-10-10T16:00:49.915Z
Required UTC Datestring
2017-10-11T00:00:00.000Z
Is there a way to use javascript to take a non-UTC date, add 1 UTC day to it, reset the time to zero, and then convert it to an ISO string?
new Date().toISOString()
2017-10-10T16:00:49.915Z
Required UTC Datestring
2017-10-11T00:00:00.000Z
In the code snippet below, I first retrieve the date in milliseconds and then add a whole day in milliseconds to it. Next, I divide the total by one day in milliseconds, truncate the result, and multiply it again by a day in milliseconds.
var d = new Date('2017-10-10T16:00:49.915Z');
function nextDayUTC(d) {
var aDay = 1440 * 60 * 1000;
var d2 = new Date( Math.trunc((d.getTime() + aDay)/aDay)*aDay);
return d2;
}
function nextDayLocal(d) {
//basically set to start of the day
//add 36 hrs, this pretty much ensures next day
//add then reset the hours back to 0
var hr36 = 36 * 60 * 60 * 1000;
var d2 = new Date(d);
d2.setHours(0,0,0,0);
d2.setTime(d2.getTime() + hr36);
d2.setHours(0,0,0,0);
return d2;
}
console.log(d)
console.log("Next Day UTC");
console.log(nextDayUTC(d).toISOString());
console.log("Next Day Local");
console.log(nextDayLocal(d).toString());
My query revolves around a React application where I have integrated Material UI for only two components. Despite installing the entire Material UI library, will this lead to an increased bundle size for my application? Or does the build process only inc ...
Greetings! I have encountered an issue where the data-native-menu="false" instruction works correctly when directly placed in a select element, but doesn't work when added to a select generated by JavaScript (using the Jeditable plugin). You can view ...
When accessing URLs directly in my Angular app either through the address bar or from external links, all routes default back to the home page. However, when navigating within the app, routes work as expected. I have come across similar issues on Stack Ov ...
There is an element with a specific ID that I have changed. However, even after changing the ID and clicking on the element with the new ID, it still triggers the function associated with the old ID. $('#1st').click(function(){ $('#1s ...
Is there a way to retrieve the duration of an animation in three.js? For example, consider the following code snippet: var mixer = new THREE.AnimationMixer(gltf.scene) gltf.animations.forEach((clip)) => { let animation = mixer.clipAction(clip) animati ...
I successfully eliminated the hash from my Angular JS website using the following code snippet: $locationProvider.html5Mode(true); Now, the previously displayed URL has been replaced with . The issue I'm facing is that when I do a hard refresh (Ct ...
I'm currently trying to pass a JavaScript variable from a range slider to a PHP query. The goal is to have the front-page of my Wordpress theme display all posts tagged with the value selected on the range slider without having to refresh the page. To ...
I've been working on a Phonegap client application and have developed all the necessary web services using Google Endpoints. However, I am facing an issue with using the API. In my index.html file, there is this script: <head><script> ...
I'm in the process of developing an online test portal within my Angular application, and I need to figure out how to automatically close/end the session when a user navigates (opens a new tab or window) to a different page. Is there a way to achieve ...
As I execute the code, an error occurs stating that setting innerText of Null is not allowed. I understand that this is because my function runs before the DOM is completely loaded, but I am unsure of how to resolve this issue. Attempts have been made usi ...
Looking to filter an array with multiple conditions? I have several checkboxes pre-checked and I need to filter based on start_date and end_date: future: start_date is after today past: end_date is after today's date in_progress: start_date is to ...
Recently, I ventured into the realm of game development and created a car game where the vehicle moves automatically. However, when the car collides with a monster, I want it to start moving towards the monster instead. After some research, I decided to in ...
I am currently utilizing this JavaScript fetch code to retrieve data from PHP async sendRequest(selectValue=this.selectValue){ const fetchResponse = await fetch('/server/getLastWords.php?select='+selectValue); const fetchJSON = await fe ...
https://i.sstatic.net/dkRt3.png The Divtag appears to be malfunctioning due to insufficient properties. I am currently unsure of how to resolve this issue and would appreciate any insights or opinions. <div class="col boardsBox" style="margin-right:0. ...
In my current setup, I have 3 buttons that can toggle between different visible divs. In the future, I may add more buttons to switch between additional divs. At the moment, the first div is active (display set to block), while all other divs are hidden ( ...
Can anyone using backbone.js lend a hand? How can error messages from a rails app be encoded when integrating with backbone.js? For instance, how should flash messages like "record not found" be handled? While errors are usually defined on the client sid ...
I have set up an express app that I want other devices on the same WIFI network to access without requiring internet connectivity. The main computer hosting the app is assigned with a fixed IP address: 192.168.1.60 In my server.js file, I have included t ...
I am looking to extract the datetime value from each element in the array below: [<time pubdate class="dt-updated" datetime="2015-07-09T11:50:32+0000" title="Time posted: 09 Jul 2015, 11:50:32 (UTC)" aria-label="Posted on 09 Jul">09 Jul</time> ...
I have a programming challenge where I need to increment one value if condition x is true, and another value if condition y is true. The issue I'm facing is that my current system also resets the value that is not being updated back to 0, which is not ...
In my Login.vue file, I successfully set a token cookie using the 'vue-cookies' package. The cookie is properly set and working. However, when I try to access the same cookie in another view, I encounter the following error in the Chrome console ...