Jump to content

Time value


sandy1028

Recommended Posts

Hi,

 

How to decrement the time from current hour of timestamp to last 24hours.

I have to manually get the time of the timestamp for last 24 hours by decrementing from the current hour

 

 

I have tried from 0th hour to 24 hours so please help me in reverse

Please help me.

 

 

 

 

 

$timeincr=10;
$time_interval = array();
for($i=0;$i<24;$i++){
        if($i<10){
                $hour = "0".$i;
        }
        else{
                $hour = $i;
        }
        for($j=0;$j<60;$j=$j+$timeincr){
                if($j==0){
                        $item = $hour.":00";
                        array_push($time_interval,$item);
                }
                else{
                        $item = $hour.":".$j;
                        array_push($time_interval,$item);
                }
        }
}



Link to comment
Share on other sites

Hi,

 

How to decrement the time from current hour of timestamp to last 24hours.

I have to manually get the time of the timestamp for last 24 hours by decrementing from the current hour

 

 

I have tried from 0th hour to 24 hours so please help me in reverse

Please help me.

 

 

 

 

 

$timeincr=10;
$time_interval = array();
for($i=0;$i<24;$i++){
        if($i<10){
                $hour = "0".$i;
        }
        else{
                $hour = $i;
        }
        for($j=0;$j<60;$j=$j+$timeincr){
                if($j==0){
                        $item = $hour.":00";
                        array_push($time_interval,$item);
                }
                else{
                        $item = $hour.":".$j;
                        array_push($time_interval,$item);
                }
        }
}



 

 

It would be gr8 if you can explain 'How to decrement the time from current hour of timestamp to last 24hours.'?

 

what you are trying to achieve why so much of scripting is required for dates?if you want time in 24 hour format you can use PHP in built function date H,i,s .

 

and to get the difference betweeon 2 dates convert the dates in timestamp and get the difference and then convert the format of that timestamp in date format you required.

 

Hope it helps a little bit

Regards

Link to comment
Share on other sites

Suppose the timestamp is 2008-01-15 12:00:01

I want the timestamp 2008-01-15 11:50:01 and so on.... decrementing for ten minutes.

 

 

 

try

 

$t= time();

echo date("m-d-Y H:i:s",$t);

$timetostop=mktime(0,0,0,date("m"),date("d")-1,date("y"));

$timetostop=date("m-d-Y",$timetostop);

$date=date("m-d-Y",$t);

while($date != $timetostop)

{

echo '<br>'.date("m-d-Y H:i:s",$t);

$t=$t-10;

$date=date("m-d-Y",$t);

}

 

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.