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.
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).
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?
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).
© 2022 OneMinuteCode. All rights reserved.