简体   繁体   中英

Updating a date field with server time from parse android sdk?

I am using Parse back-end, and i have a Date field which i need to fill with Server time. But i am updating this from Android-SDK and i want to update it with server time. (I don't want to take local time from mobile and convert as it is not reliable, may be if the user's time was wrong)

You can use beforeSave cloud method hook for such scenarios.

Parse.Cloud.beforeSave("YourClassName", function(request, response) {
   request.object.set("yourDateField", new Date());
   response.success();
});

This will set "yourDateField" with the server time stamp (GMT) before inserting the row into the Class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM