vo-q
11/29/2017 - 4:45 PM

Corvert string to timestamp

extension String {
  func convertStringDateToTimeStamp(_ dateFormat: String) -> Int? {
  		
  		let dateFormatter = DateFormatter()
  		dateFormatter.dateFormat = dateFormat
  		let date = dateFormatter.date(from: self)
  		if let date = date {
  			let timeStamp = Int(date.timeIntervalSince1970 * 1000)
  			return timeStamp
  		}
  		
  		return nil
  	}
}