Start a new topic

Getting a Timestamp from the Kinvey Server

We need to create 3 timestamps for the images and videos that we are creating and uploading to Files. 1 for the creation of the file, 1 for the time sent to the server, and 1 one received by the server. The 3rd one is created automatically for us by the server. For security reasons, we do not want to rely on the device for timestamps and would like to keep all timestamps from the same source. What is the best method for retrieving a timestamp from the Kinvey server?


Michael,


Kinvey automatically adds metadata for all entities when they are created or modified on the server. Please take a look at https://devcenter.kinvey.com/rest/guides/datastore#Metadata.


Please take a look at date library which you can use in Kinvey Business Logic.

https://devcenter.kinvey.com/rest/reference/business-logic/reference.html#moment-module


This is the code which helps you get the current date in the BL and then you can use that to store in the collection:


var moment = modules.moment().format();
  var logger = modules.logger;
  logger.info(moment);
  response.continue();


Also, please take a look at different modules available for BL:

https://devcenter.kinvey.com/rest/reference/business-logic/reference.html#modules


Thanks,

Pranav

Thank you for your response. I just want to clarify that the moment module and the code you showed me are for a custom endpoint solution.


Is there a way to get a timestamp from the server without creating a custom endpoint?

Login or Signup to post a comment