Jump to content

Recommended Posts

so essenetially you want to split a 24hour period equally and show it as a timestamp? or something like that? although your example does exclude the first minute of said period.

 

I am guessing this split could be 2,3 ,4 or more? thus becoming 12hr,8hr,6hr etc periods?

 

 

 

Sanity prevails

 

<?php
    $numdivs = 3; // or however many you need
    
    $divsecs = 86400/$numdivs;
    
    $basedate = '2010-01-01';
    $basetime = strtotime($basedate);
    
    echo '<pre>';
    for($i=0; $i < $numdivs; $i++) {
        $t1 = $basetime + $i * $divsecs;
        $t2 = $t1 + $divsecs - 1;
        printf ('%s to %s<br>', date('d M Y H:i:s', $t1), date('H:i:s', $t2));
    }
    echo '</pre>';
?>

 

-->

 

01 Jan 2010 00:00:00 to 07:59:59

01 Jan 2010 08:00:00 to 15:59:59

01 Jan 2010 16:00:00 to 23:59:59

Sanity prevails

 

Another reason I wanted to close this thread is because of this.  While this code does something, we have no way of knowing if it's what OP wanted.  the "problem" you solved was someone's random guess as to what OP could possibly have meant. 

Sanity prevails

 

Another reason I wanted to close this thread is because of this.  While this code does something, we have no way of knowing if it's what OP wanted.  the "problem" you solved was someone's random guess as to what OP could possibly have meant. 

 

At least it's a reasonable interpretation of his post, unlike some of the more inane comments. You should at least give the OP a chance to respond.

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.