Introduction
This tutorial will show how to capture date and time from a PC ou mobile device and insert this data in your C2's project.
What is required?
You need to insert in your project the Browser object and to use the expression ExecJS("Date()").
The expression ExecJS runs a Javascript code and return a result if it is a string or number, and the code Date() returns the actual date and time like the example in the image below:
The code always returns in the fomat Abbreviated Weekday, Abbreviated Month, Day of the Month, Hours:Minutes:Seconds.
How to use
You can to store date and time in a local or global variable using the action Set value and the expression Browser.ExecJS("Date()"). You can to show directly in a Text object with the action Set text.
Both in the Scirra Arcade as in the CAPX attached in this tutorial there is a simple example using the expression. Only 2 events were used:
The example shows continuously the current date and hour every second.
Limitations
The Javascript code just returns date and time as mentioned above. I tried to use other comands to capture only date or time, but Construct 2 alerted me about the risks in to use same codes and stopped the execution. In the manual there is a explanation about this.
For now, if you need to capture only date or time, use system expressions such as left and right.
Note: AllanR told me about the plugin of rexrainbow, System date and time. You can use it instead of this tutorial.