Jump to content

Divide a single date


ajithsk

Recommended Posts

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

Link to comment
Share on other sites

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. 
Link to comment
Share on other sites

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.

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.