PHP: Best way to convert a datetime to just time string?
问题 I have a datetime that I pulled from the database that looks like this: 2000-01-01 08:00:00 Now I need to convert it so all I have left is: 08:00:00 What is the best way to do this? 回答1: substr('2000-01-01 08:00:00', 11); 回答2: You could use substr($timestamp, -8); 回答3: you can also use the php strtotime function to turn it into a datetime object, then use the format method on it to get a pretty representation however you want. That way you can put in am/pm, do 24 hour or 12 hour, do whatever