ajithsk Posted September 12, 2012 Share Posted September 12, 2012 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 Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/ Share on other sites More sharing options...
spiderwell Posted September 12, 2012 Share Posted September 12, 2012 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 Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377190 Share on other sites More sharing options...
ajithsk Posted September 12, 2012 Author Share Posted September 12, 2012 Hi, I dont want spliting a date into year, month and date. Instead I need 2012-01-01 itself to be divided Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377203 Share on other sites More sharing options...
ManiacDan Posted September 12, 2012 Share Posted September 12, 2012 Divided into what? Show a before and after. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377205 Share on other sites More sharing options...
Jessica Posted September 12, 2012 Share Posted September 12, 2012 Dan, don't you know there are 3 quirklocks in a day? Sheesh. This is basic stuff, why can't PHP do it magically? Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377213 Share on other sites More sharing options...
litebearer Posted September 12, 2012 Share Posted September 12, 2012 (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) ? Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377241 Share on other sites More sharing options...
spiderwell Posted September 12, 2012 Share Posted September 12, 2012 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? Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377254 Share on other sites More sharing options...
ManiacDan Posted September 12, 2012 Share Posted September 12, 2012 That was a different poster. OP still hasn't told us what he means, we're all just guessing. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377260 Share on other sites More sharing options...
premiso Posted September 12, 2012 Share Posted September 12, 2012 I want to divide by 0. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377261 Share on other sites More sharing options...
Jessica Posted September 12, 2012 Share Posted September 12, 2012 Quote I want to divide by 0. In Soviet Russia, 0 divides YOUUUUUU Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377264 Share on other sites More sharing options...
premiso Posted September 12, 2012 Share Posted September 12, 2012 Quote In Soviet Russia, 0 divides YOUUUUUU Chuck Norris is the only known person to have successfully divided by zero. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377266 Share on other sites More sharing options...
Jessica Posted September 12, 2012 Share Posted September 12, 2012 Quote Quote 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. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377271 Share on other sites More sharing options...
ManiacDan Posted September 12, 2012 Share Posted September 12, 2012 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. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377276 Share on other sites More sharing options...
ManiacDan Posted September 12, 2012 Share Posted September 12, 2012 Unlocked on the off chance OP has something to say, and because Jesi's had a bad day. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377284 Share on other sites More sharing options...
Jessica Posted September 12, 2012 Share Posted September 12, 2012 Woot woot. I'll behave now. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377289 Share on other sites More sharing options...
premiso Posted September 12, 2012 Share Posted September 12, 2012 Quote I'm going to close this thread before it turns into a meme contest. =\ I thought that was the whole point of this thread... Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377292 Share on other sites More sharing options...
Barand Posted September 12, 2012 Share Posted September 12, 2012 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 https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377315 Share on other sites More sharing options...
ManiacDan Posted September 12, 2012 Share Posted September 12, 2012 Quote 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 https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377350 Share on other sites More sharing options...
Jessica Posted September 12, 2012 Share Posted September 12, 2012 Dan you can close it, I don't care :-P Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377353 Share on other sites More sharing options...
ManiacDan Posted September 12, 2012 Share Posted September 12, 2012 Quote Dan you can close it, I don't care :-P Maybe he'll come back. Link to comment https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377362 Share on other sites More sharing options...
Barand Posted September 12, 2012 Share Posted September 12, 2012 Quote Quote 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 https://forums.phpfreaks.com/topic/268283-divide-a-single-date/#findComment-1377363 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.