Lee Kraus
Posts: 0
Joined: Mon Jan 05, 2015 12:54 am

Pushing the Current Date & Time to database

How do I push the current data and time into a date field in my database when I save a record? i.e. I what to save a started_at time in addition to the created_at time to indicate an event has started.

Thank you.

Lee Kraus
Posts: 0
Joined: Mon Jan 05, 2015 12:54 am

Pushing the Current Date & Time to database

It didn't work for me. Not sure if I am putting it in the wrong place? It is in the JS on the field in the request mapping component.

Lee Kraus
Posts: 0
Joined: Mon Jan 05, 2015 12:54 am

Pushing the Current Date & Time to database

Nevermind, I got it to work. I need to change the timezone on my database. how do I do that?

Thank you!!!

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Pushing the Current Date & Time to database

Lee,

Unfortunately this cannot be done, all dates are written with UTC, if it is necessary, you can transfer them in the application

Lee Kraus
Posts: 0
Joined: Mon Jan 05, 2015 12:54 am

Pushing the Current Date & Time to database

is there an easy formula to do that? I am not a programmer.

Thank you!

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Pushing the Current Date & Time to database

Well, assuming I understand you correctly, you just need this method

var UTCstring = (new Date()).toUTCString();

But do remember that the date values you get are based on the clock of the client's machine, not your server

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Pushing the Current Date & Time to database

And how would you use that?

You can add a new col / field in your table called _insertedAt or something...and then in your mapping when you call the REST API / or within your Before Send - add the following in the "JS" for that column

var UTCstring = (new Date()).toUTCString();
return (UTCstring);

This will supply the client side time (in UTC, of course) to the REST Call and that way you can have the record insertion time

Lee Kraus
Posts: 0
Joined: Mon Jan 05, 2015 12:54 am

Pushing the Current Date & Time to database

Thank you. I will test. I appreciate the support.

Return to “Issues”