snowman15 Posted September 2, 2007 Share Posted September 2, 2007 I'm trying to figure out how to get php variables as the time. One variable for the hour and one variable for the minute or one variable for both. Right now im looking at this example that i found on google.. <?php $localtime_assoc = localtime(time(), true); print_r($localtime_assoc); ?> Its outputting.. Array ( [tm_sec] => 24 [tm_min] => 3 [tm_hour] => 19 [tm_mday] => 3 [tm_mon] => 3 [tm_year] => 105 [tm_wday] => 0 [tm_yday] => 92 [tm_isdst] => 1 ) So my question is, how do I take the array value's of [tm_min] and [tm_hour] and get them into php integer variables such as $hour and $minute? Any other easy ways to do this that doesn't involve this code? thanks everyone! Quote Link to comment https://forums.phpfreaks.com/topic/67677-solved-how-to-use-php-time/ Share on other sites More sharing options...
Fadion Posted September 2, 2007 Share Posted September 2, 2007 U mean something like this: list($hour, $min, $sec) = explode(':', date('h:i:s')); echo $hour . "-" . $min . "-" . $sec; There are 3 variables, for hours, minutes and seconds. Take a look at date(). Quote Link to comment https://forums.phpfreaks.com/topic/67677-solved-how-to-use-php-time/#findComment-339964 Share on other sites More sharing options...
Hypnos Posted September 2, 2007 Share Posted September 2, 2007 So my question is, how do I take the array value's of [tm_min] and [tm_hour] and get them into php integer variables such as $hour and $minute? Any other easy ways to do this that doesn't involve this code? $hour = $localtime_assoc['tm_hour']; $minute = $localtime_assoc['tm_min']; Or you could just do this: $hour = date('h'); $minute = date('i'); Quote Link to comment https://forums.phpfreaks.com/topic/67677-solved-how-to-use-php-time/#findComment-339978 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.