Hi all,
How can one show thew current day? I tried using the normal dateformatter option, but it doesn't seem to work. Below is my code:
How can one show thew current day? I tried using the normal dateformatter option, but it doesn't seem to work. Below is my code:
Code Block struct CPClockWidgetEntryView : View { static var dateformatter: DateFormatter = { // Get Current Date: let dateformatter = DateFormatter() dateformatter.dateStyle = .medium // Get Day of Week: let theWeekday = Calendar(identifier: .gregorian) let currentDay = theWeekday.component(.weekday, from: Date()) return dateformatter }() var currentDate = Date() var currentDay = Date() var entry: Provider.Entry var body: some View { ZStack { Color.black .edgesIgnoringSafeArea(.all) VStack { Text("Today Is:") .background(Color.black) .foregroundColor(Color.white) .font(.custom("DIN Alternate-Bold", size: 25)) .multilineTextAlignment(.center) let dateTimeString = PlaceholderView.CPClockWidgetEntryView.dateformatter.string(from: currentDate) Text("\(dateTimeString)") .background(Color.black) .foregroundColor(Color.white) .font(.custom("DIN Alternate-Bold", size: 30)) .multilineTextAlignment(.center) let dateTimeString2 = PlaceholderView.CPClockWidgetEntryView.dateformatter.string(from: currentDay) Text("\(dateTimeString2)") .background(Color.black) .foregroundColor(Color.white) .font(.custom("DIN Alternate-Bold", size: 30)) .multilineTextAlignment(.center) } } } }