Math with time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

I found it quite difficult to understand but I'm use to it now, it just this looks better

Code: Select all

<?php
$num = $num + 6;
?>
than

Code: Select all

<?php
$num += 6;
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I do LOVE +=, |= and so on :D
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

mydimension wrote:for readability sake, most people find that += is to hard to understand at a quick glance.
IMHO, I think that using it makes things more readable because it has a very specific function. Meaning that at a quick glance

Code: Select all

$var1 += $var2;
is easier to read than

Code: Select all

$var1 = $var1 + $var2;
because you don't have to pay too much attention to the first one.

Like any language some things are a bit tough at first but once you've looked up operators in the manual all those +='s and .='s start to make a bit more sense.

Mac
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post by Zoram »

If i am just interested in the hours not how many days it adds up to and all is there a way to just have hours.. (ex instead of 13 days have 312 hours?)
Post Reply