You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
846 B

  1. //
  2. // DateFormatterExtension.swift
  3. // GMERemittance
  4. //
  5. // Created by gme_2 on 03/10/2018.
  6. // Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. extension DateFormatter {
  10. static func toDate(dateString: String, format: String = AppConstants.dateFormat) -> Date? {
  11. let dateFormatter = DateFormatter()
  12. dateFormatter.dateFormat = format
  13. // dateFormatter.locale = Locale(identifier: "en_Us")
  14. return dateFormatter.date(from: dateString)
  15. }
  16. static func toString(date: Date, format: String = AppConstants.humanReadableDateFormat) -> String {
  17. let dateFormatter = DateFormatter()
  18. dateFormatter.dateFormat = format
  19. // dateFormatter.locale = Locale(identifier: "en_US")
  20. return dateFormatter.string(from: date)
  21. }
  22. }