Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift calendar components

// *** Create date ***
let date = Date()

// *** create calendar object ***
var calendar = Calendar.current

// *** Get components using current Local & Timezone ***
print(calendar.dateComponents([.year, .month, .day, .hour, .minute], from: date))

// *** define calendar components to use as well Timezone to UTC ***
calendar.timeZone = TimeZone(identifier: "UTC")!

// *** Get All components from date ***
let components = calendar.dateComponents([.hour, .year, .minute], from: date)
print("All Components : (components)")

// *** Get Individual components from date ***
let hour = calendar.component(.hour, from: date)
let minutes = calendar.component(.minute, from: date)
let seconds = calendar.component(.second, from: date)
print("(hour):(minutes):(seconds)")
Comment

swiftui calendar

@State private var date = Date()

var body: some View {
    DatePicker(
        "Start Date",
        selection: $date,
        displayedComponents: [.date]
    )
    .datePickerStyle(.graphical)
}
Comment

PREVIOUS NEXT
Code Example
Swift :: add navigation bar button swiftui 
Swift :: hide scroll view indicators bar swiftui 
Swift :: remove cocoapods swiftr 
Swift :: swift dictionary contains key 
Swift :: swift uitextfield placeholder color 
Swift :: How to hide view in swiftui 
Swift :: swift 5 make image fit uiimageview 
Swift :: white status bar swift 
Swift :: xcode how to know which textfield is selected 
Swift :: switch button swift 5 
Swift :: convert image to base64 swift Ui 
Swift :: swiftui textfield focus 
Swift :: Play Video in AVPlayer ViewController Sample Code Swift 
Swift :: swift extension Array where type 
Swift :: swift int max 
Swift :: uikit call swiftui view 
Swift :: two value sum 
Swift :: Swift Syntax of guard Statement 
Swift :: after redirect from another viewcontroller in swift 5 make full view view controller 
Swift :: Swift Symmetric Difference between Two Sets 
Swift :: Access Array Elements Using Swift Range 
Swift :: Swift Library Function 
Swift :: Swift Bitwise NOT Operator 
Swift :: helen joseph 
Swift :: protocol oriented programming swift github Basic 
Swift :: how to unwrap arrays with optional value in swift 
Swift :: swift error handling 
Swift :: how to convert a url to string in swift 
Ruby :: devise generate controller 
Ruby :: devise add trackable 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =