Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift get day from available string


let dateString = "2018-12-24 18:00:00 UTC"
    let formatter = DateFormatter()
    formatter.dateFormat = "yyyy-MM-dd HH:mm:ss 'UTC'"
    guard let date = formatter.date(from: dateString) else {
        return
    }

    formatter.dateFormat = "yyyy"
    let year = formatter.string(from: date)
    formatter.dateFormat = "MM"
    let month = formatter.string(from: date)
    formatter.dateFormat = "dd"
    let day = formatter.string(from: date)
    print(year, month, day) // 2018 12 24
Comment

PREVIOUS NEXT
Code Example
Swift :: swift swipe gesture 
Swift :: ios rounded button 
Swift :: return multiple values from a function swift 
Swift :: Save structure in userdefaults ios swift 
Swift :: get index filter swift 
Swift :: prevent iphone to sleep swift 
Swift :: swiftui circle 
Swift :: add top corner radius swift 
Swift :: alert swiftui 
Swift :: costume font size swift ui 
Swift :: unit testing swift 
Swift :: swift date difference in days 
Swift :: swift url request 
Swift :: NumberFormatter swift 
Swift :: swift date to string 
Swift :: swiftui create search bar 
Swift :: init with bindings swiftui 
Swift :: swiftui coin flip 
Swift :: Equatable Function Swift 
Swift :: remove and element from array firebase swift 5 
Swift :: save file with % swift 
Swift :: swift how to set warning message 
Swift :: how to change background color swift 
Swift :: swift reload view 
Swift :: after redirect from another viewcontroller in swift 5 make full view view controller 
Swift :: swift print struct name 
Swift :: Swift guard Statement Inside a Function 
Swift :: Why Inheritance? 
Swift :: crud php native with navicat 
Swift :: Swift String and Character Literals 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =