Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift get current hour

let date = Date() // save date, so all components use the same date
let calendar = Calendar.current // or e.g. Calendar(identifier: .persian)

let hour = calendar.component(.hour, from: date)
let minute = calendar.component(.minute, from: date)
let second = calendar.component(.second, from: date)
Comment

swift get current hour

let hour = Calendar.current.component(.hour, from: Date())
Comment

swift get current hour

let formatter = DateFormatter()
formatter.dateFormat = "hh a" // "a" prints "pm" or "am"
let hourString = formatter.string(from: Date()) // "12 AM"
Comment

PREVIOUS NEXT
Code Example
Swift :: map swift 
Swift :: swift try catch 
Swift :: simple alert swifti 
Swift :: average in array swift 
Swift :: objective c vs swift 
Swift :: how to merge 2 arrays in swift 
Swift :: swift 5 to upper 
Swift :: swiftui tabview background color 
Swift :: swiftui radio button 
Swift :: Play Video in AVPlayer Sample Code Swift 
Swift :: swift extension Array with specific element type 
Swift :: swift 5 change message color of alert 
Swift :: while loop in swift 
Swift :: ios get notification payload 
Swift :: share local storage wkwebview swift 
Swift :: swift hide button 
Swift :: move view controller to make space for keyboard swift 5 
Swift :: Swift enum With Associated Values 
Swift :: get parent view controller in presentation mode swift 
Swift :: swift array chunks 
Swift :: appendBytes: Lengt: SWIFT 
Swift :: single word search swift 
Swift :: image copy swift extension 
Swift :: Error with preview @FocusState SwiftUI 
Swift :: swift function return type 
Swift :: remove grey background when selecting cells from uitableview swift after selection 
Swift :: uialertcontroller example objective Code Answer 
Ruby :: ruby variable in string 
Ruby :: convert string to hash ruby 
Ruby :: ruby check if exists 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =