# Divide a single date

## Recommended Posts

Hi,

I want to divide a date into half or anyway.

Suppose for eg. I want to take records of date in 2010-01-01, I want that to be divided into equal intervals and after that I want output interval as date itself.

Is it possible in php

Regards

Ajith

##### Share on other sites

Despite your example, I still have no idea what you mean. are you looking to split the date up into month,year,day?

by divide what do you mean? as this is also a maths function. please clarify further

thanks

##### Share on other sites

Hi,

I dont  want spliting a date into year, month and date. Instead I need 2012-01-01 itself to be divided

##### Share on other sites

Divided into what?  Show a before and after.

##### Share on other sites

Dan, don't you know there are 3 quirklocks in a day? Sheesh. This is basic stuff, why can't PHP do it magically?

##### Share on other sites

(20120-1-01 00:01 - 20120-1-01 07:59) ;

(20120-1-01 08:00 - 20120-1-01 15:59) ;

(20120-1-01 16:00 - 20120-1-01 11:59)

?

##### Share on other sites

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?

##### Share on other sites

That was a different poster.  OP still hasn't told us what he means, we're all just guessing.

##### Share on other sites

I want to divide by 0.

##### Share on other sites

I want to divide by 0.

In Soviet Russia, 0 divides YOUUUUUU

##### Share on other sites

In Soviet Russia, 0 divides YOUUUUUU

Chuck Norris is the only known person to have successfully divided by zero.

##### Share on other sites

In Soviet Russia, 0 divides YOUUUUUU

Chuck Norris is the only known person to have successfully divided by zero.

I don't always do division, but when I do, I always divide by 0.

##### Share on other sites

Based on OP's only other post, we're not going to get a better explanation out of them, so I'm going to close this thread before it turns into a meme contest.

##### Share on other sites

Unlocked on the off chance OP has something to say, and because Jesi's had a bad day.

Woot woot.

I'll behave now.

##### Share on other sites

I'm going to close this thread before it turns into a meme contest.

=\ I thought that was the whole point of this thread...

##### Share on other sites

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

##### 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.
##### Share on other sites

Dan you can close it, I don't care :-P

##### Share on other sites

Dan you can close it, I don't care :-P

Maybe he'll come back.
##### 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.

##### 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.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.