Given a Unix timestamp, how to get beginning and end of that day?
问题 I have a Unix timestamp like this: $timestamp=1330581600 How do I get the beginning of the day and the end of the day for that timestamp? e.g. $beginOfDay = Start of Timestamp's Day $endOfDay = End of Timestamp's Day I tried this: $endOfDay = $timestamp + (60 * 60 * 23); But I don't think it'll work because the timestamp itself isn't the exact beginning of the day. 回答1: strtotime can be used to to quickly chop off the hour/minutes/seconds $beginOfDay = strtotime("today", $timestamp);