func toCheckTimeFormatFromDevice(){
if Date.is24HoursFormat_1 == true{
print("phone is set to 24 hours")
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone(abbreviation: "GMT") //Set timezone that you want
dateFormatter.locale = NSLocale.current
dateFormatter.dateFormat = "hh:mm a" //Specify your format that you want
let strDate = dateFormatter.string(from: date)
print(strDate)
}else{
print("phone is set to 12 hours")
}
}
我已将设备的当前时间格式设置为24小时,现在我想将时间以12小时格式转换为“ am”,“ pm”。
答案 0 :(得分:0)
您可以使用以下方法。它对我有用
<header class="header">
<nav class="navbar">
Navbar
</nav>
<div class="header-overlay">
This is the overlay
</div>
</header>