I'm trying to calculate the date and time.
Codepen shows the results in the log without any problems, but
If you try monaca, it will be null.
It was not possible to specify the date and time directly for the new Date() instead of the variable.
I don't know the cause, thank you for your cooperation.
vargg='2015-12-3123:59'; varff='2015-12-3123:56'; vara = new Date(gg); varb = new Date(ff); vardd = a-b; console.log(dd);
I can't say for sure because I don't have running environment information (IDE preview or iOS/Android debugger), but I remember that I couldn't use console.log with iOS version of Monaca debugger.
When I ran the source provided, my environment (Windows 8.1, Chrome 43, iOS 8.3, Monaca Debugger 4.0.1) didn't even print null in the first place.
According to the official documentation,
As for iOS apps, the Mac's Safari remote debugging capability and Monaca debugger can be combined to perform debugging.This allows you to use the following features:
Debugging using the Console—Provides message output and debug sessions on the Console.
It says.Conversely, if you don't use the Mac+Safari remote debugging feature, you can read that console is not available.I was able to confirm that the IDE preview would output console.log, although the iOS Monaca debugger did not output anything.
The date format string passed to the Date object does not conform to the standard format and is therefore not interpreted correctly depending on the browser implementation.
(After executing the source code provided, Chrome 43 said 180,000 but Firefox 38 said NaN.)
I don't know how iOS/Android WebView interprets the format '2015-12-3123:59', but for safety reasons, it should be in some standard format (the following is an example of ISO 8601).
vargg='2015-12-31T23:59:00+0900'; varff='2015-12-31T23:56:00+0900'; vara = new Date(gg); varb = new Date(ff); vardd = a-b; console.log(dd);
Please refer to the following page for the format of the date string.
iOS Debugger (4.0.1), on iOS 8.3
Android Debugger (4.0.2), on Android 5.1.1 Verified in .
Don't worry, the console.log content will appear on the device.
The main reason why console.log(dd); is null is that gg and ff are not properly recognized as date strings, and a and b fail to generate date objects.
Now, how should I write it on gg and ff?
vargg='2015/12/31 23:59'; varff='2015-12-31T23:56:00.000+09:00';
and so on.
In other words, the date and time should be separated by 」/ に instead of -- 」, or
If you want to follow the format, use yyyy-mm-ddTtt:mm:ss.sss+mm:ss (where +09:00 is Japan Standard Time).
vargg='2015/12/31 23:59'; varff='2015-12-31T23:56:00.000+09:00'; vara = new Date(gg); varb = new Date(ff); console.debug("a-localestr" + a.toLocaleString()); console.log("b-localestr" + b.toLocaleString()); console.debug("a-gettime" + a.getTime()); console.log("b-gettime" + b.getTime()); vardd = a-b; varee = a.getTime()-b.getTime(); console.log("dd"+dd); console.log("ee"+ee);
356 I want to create an array of sequences from "1" to a specified number.
356 Unity Virtual Stick Does Not Return to Center When You Release Your Finger
371 Update Flask User Information
339 Scrap text information after the "View More" button when searching in the Yahoo! News search window
© 2023 OneMinuteCode. All rights reserved.