Ruth
Posts: 0
Joined: Thu Nov 07, 2013 12:24 pm

database time stamp

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

database time stamp

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.

Ruth
Posts: 0
Joined: Thu Nov 07, 2013 12:24 pm

database time stamp

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

database time stamp

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

database time stamp

Hi Ruth,

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

Ruth
Posts: 0
Joined: Thu Nov 07, 2013 12:24 pm

database time stamp

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.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

database time stamp

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.

Ruth
Posts: 0
Joined: Thu Nov 07, 2013 12:24 pm

database time stamp

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?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

database time stamp

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.

Ruth
Posts: 0
Joined: Thu Nov 07, 2013 12:24 pm

database time stamp

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.

Return to “Issues”