Page 1 of 2

database time stamp

Posted: Wed Nov 13, 2013 5:21 pm
by Ruth

I am using Appery database to store photos taken on device and then calling all photos in database up to view. along with the photo I am calling I am calling up the created at column so that I know at what time the photo was taken.
the problem is the time stamp from the database is ahead about 5 hours. Can this be changed?


database time stamp

Posted: Wed Nov 13, 2013 6:09 pm
by maxkatz

The time stamp is in database is in GMT. You could create another column to keep data in your time zone or simply covert the time when you read the date.


database time stamp

Posted: Wed Nov 13, 2013 7:20 pm
by Ruth

What would the code to convert the when I read the date? We are in EST.


database time stamp

Posted: Wed Nov 13, 2013 7:23 pm
by maxkatz

You would need to use JavaScript to convert the data. You can look into using moment.js library to help you with that.


database time stamp

Posted: Wed Nov 13, 2013 7:27 pm
by Kateryna Grynko

Hi Ruth,

You can use toUTCString: https://developer.mozilla.org/en-US/d...


database time stamp

Posted: Tue Nov 19, 2013 9:06 pm
by Ruth

I have worked with the UTC & moment.js, I have had no success.

can you tell me what the JS would be to convert the GMT to EST or at least subtract 5 hours from the time and if so were would I add it.

I have shared the project with you.


database time stamp

Posted: Tue Nov 19, 2013 10:23 pm
by Alena Prykhodko

Hi Ruth,

You can try the following:pre
var timeNow = new Date();
var d = new Date(timeNow.getTime() - 18000000);/pre

Where variable d stores 5 hours subtracted time from current.
18000000- 5 hours in ms.


database time stamp

Posted: Wed Nov 20, 2013 2:04 am
by Ruth

were would I place the code? in js file, or as we pull the info out of list service and place it in the label?


database time stamp

Posted: Wed Nov 20, 2013 2:28 am
by Alena Prykhodko

Any custom JavaScript code goes into Run JavaScript action, as JavaScript file or as add JS in mapping. It depends on your app logic.
You can use last approach.


database time stamp

Posted: Wed Nov 20, 2013 1:42 pm
by Ruth

I have tried the above code in js action, file and mapping and it either does nothing or it freezes the loading.

I am using the _createdAt column from the data base. logically I think it should be places in the mapping when I am using the list service when I do it will not load the page.

option2

is to add the date when I take the picture and send it to the database.

I have tired using the following code as run js when I click the button but the result is opening in a new window.