Reputation: 1133
Sounds like a silly queston, but I need a quick answer and could not find it.
I have a timestamp: '15:40:00', and I need to create two separate variables: hours and minutes.
Much much appreciated.
Upvotes: 1
Views: 121
Reputation: 43582
You can also use one function sscanf()
(variables will be integer
type) :
sscanf('15:40:00', '%d:%d:%d', $hours, $minutes, $seconds);
Upvotes: 1
Reputation: 219934
list()
and explode()
work well here.
list($hours, $minutes, $seconds) = explode(':', '15:40:00');
Upvotes: 2