Jump to content

[SOLVED] How to use PHP Time????


snowman15

Recommended Posts

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!

Link to comment
Share on other sites

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');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.