I am making my own app, which involves uploading pictures and the date in which the post was made is necessary. I was wondering how I can upload this data to parse, and then how to retrieve it from parse to populate it in a label.
Best regards
I am making my own app, which involves uploading pictures and the date in which the post was made is necessary. I was wondering how I can upload this data to parse, and then how to retrieve it from parse to populate it in a label.
Best regards
You will first ask your backend that in which format he needs the date. Suppose he says "yyyy-MM-dd'T'HH:mm:ss.000Z"
Then you will do this
let date = Date()
this will give you current date object there are other ways too you can take date object for eg. date picker. Then
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.000Z"
let dateString = dateFormatter.string(from: date!)
now in dateString
you'll get the date in string which you will send and at the time of receiving you'll again get date in String in some specific format to convert that string to Date Object do the following.
Suppose dateData is the var in which you stored the dateString received from the API.
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.000Z" // put here the date format told by your backend developer
let date = dateFormatter.date(from: dateData)