How do I delete time zone using Browser.ExecJS("Date()")

Get help using Construct 2

Post » Tue Mar 20, 2018 3:30 pm

Image
https://ibb.co/mx7ALH

When I sue Browser.ExecJS("Date()") I get the time the date and the time zone, is there a way to prevent the time zone from displaying ?
B
38
S
18
G
4
Posts: 43
Reputation: 4,980

Post » Tue Mar 20, 2018 6:15 pm

Perhaps someone could teach me an easier way to go about this but I’d write a simple js file that gives you the specific part of the date you are looking for and run it with Valera Popov’s JS plugin. I’m very new to this kind of stuff, so there may be a way to do this with the browser object but I haven’t found it. I’m not sure whether you’re new to js like I am or not but if it is at all helpful, here is a link explaining how to get the current year in js (as an example). https://stackoverflow.com/questions/600 ... javascript
B
80
S
48
G
31
Posts: 424
Reputation: 23,023

Post » Tue Mar 20, 2018 7:10 pm

@ultrafop thank you so much for your suggestion I'm learning js so I'm new, and the link you suggested is very helpful, but i'm thinking it could be a simple solution,
there is a plugin by Rex but i'm trying to limit plugins as possible
also found this from ([url]@ultrafop thank you so much for your suggestion I'm learning js so I'm new, and the link you suggested is very helpful, but i'm thinking it could be a simple solution,
there is a plugin by Rex but i'm trying to limit plugins as possible
also found this from https://www.scirra.com/tutorials/940/how-to-easily-capture-date-and-time-and-insert-them-in-a-project :

Browser.ExecJS("var currentdate = new Date(); currentdate.getFullYear() & '-' & (currentdate.getMonth() 1) & '-' & currentdate.getDate() & ' ' & currentdate.getHours() & ':' & currentdate.getMinutes() & ':' & currentdate.getSeconds();")

but didn't work, maybe there some syntax error ?
B
38
S
18
G
4
Posts: 43
Reputation: 4,980

Post » Tue Mar 20, 2018 7:19 pm

Yo! Valera's plugin has an MIT license so you can use it so long as he's credited.You can't set new variables in the browser object (If I'm wrong, can someone show me how?), so you'll have a tough time with code like that. If the only issue is the time info at the end of your date you could also just make the textbox a size that cuts that part off.
B
80
S
48
G
31
Posts: 424
Reputation: 23,023

Post » Tue Mar 20, 2018 7:55 pm

thx again for the suggestion and i think I'm going to go with limiting the size of the textbox, the only issue with that is because the number of characters is not set ( variable and depend on each date ) I might end up with an extra character that doesn't make sense at the end :p but yeah...
B
38
S
18
G
4
Posts: 43
Reputation: 4,980


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests