我想打印出星期几的日期,现在我正在使用以下字符串从星期一获取日期:
$current_dayname = date("l");
echo $date = date("Y-m-d",strtotime('monday this week'));
它有效,在星期一早上,我将从星期一开始获取日期。现在,我要完成的工作是从星期六开始打印下周一的日期。我该怎么办?
答案 0 :(得分:1)
您可以尝试以下代码:
func locationManager(_ manager: CLLocationManager, didUpdateLocations
locations: [CLLocation]) {
let userLocation :CLLocation = locations[0] as CLLocation
// Convert location into object with human readable address components
CLGeocoder().reverseGeocodeLocation(userLocation) { (placemarks, error) in
// Check for errors
if error != nil {
print(error ?? "Unknown Error")
} else {
if let placemark = placemarks?[0] {
var streetAddress = ""
if placemark.subThoroughfare != nil && placemark.thoroughfare != nil {
streetAddress = placemark.subThoroughfare! + " " + placemark.thoroughfare!
// self.address.text = streetAddress
} else {
print("Unable to find street address")
}
// Same as above, but for city
var city = ""
// locality gives you the city name
if placemark.locality != nil {
city = placemark.locality!
// self.city.text = city
} else {
print("Unable to find city")
}
// Do the same for state
var state = ""
// administrativeArea gives you the state
if placemark.administrativeArea != nil {
state = placemark.administrativeArea!
} else {
print("Unable to find state")
}
// And finally the postal code (zip code)
var zip = ""
if placemark.postalCode != nil {
zip = placemark.postalCode!
} else {
print("Unable to find zip")
}
var country = ""
if placemark.country != nil {
country = placemark.country!
self.city.text = country
} else {
print("Unable to find zip")
}
DispatchQueue.main.async {
self.address.text = String("\(streetAddress)\n\(city), \(state) \(zip)")
}
}
}
}
}
这应该给您下一个星期一的日期。
这也将起作用:
echo $date = date("Y-m-d",strtotime('monday next week'));