Rabu, 04 September 2013

PHP Indonesia - Facebook: can anyone tell me why my script is not returning ...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Marketing Mobile Apps

This online course focuses on marketing efforts that will increase your app's exposure and establish a mobile app marketing plan. Enroll today for $99.
From our sponsors
can anyone tell me why my script is not returning ...
Sep 4th 2013, 11:18, by Arup Debnath

Arup Debnath 11:18am Sep 4
can anyone tell me why my script is not returning anything??? plz??
<?php
function distanceOfTimeInWords($fromTime, $toTime = 0, $showLessThanAMinute = false) {
$distanceInSeconds = round(abs($toTime - $fromTime));
$distanceInMinutes = round($distanceInSeconds / 60);

if ( $distanceInMinutes <= 1 ) {
if ( !$showLessThanAMinute ) {
return ($distanceInMinutes == 0) ? 'less than a minute' : '1 minute';
} else {
if ( $distanceInSeconds < 5 ) {
return 'less than 5 seconds';
}
if ( $distanceInSeconds < 10 ) {
return 'less than 10 seconds';
}
if ( $distanceInSeconds < 20 ) {
return 'less than 20 seconds';
}
if ( $distanceInSeconds < 40 ) {
return 'about half a minute';
}
if ( $distanceInSeconds < 60 ) {
return 'less than a minute';
}

return '1 minute';
}
}
if ( $distanceInMinutes < 45 ) {
return $distanceInMinutes . ' minutes';
}
if ( $distanceInMinutes < 90 ) {
return 'about 1 hour';
}
if ( $distanceInMinutes < 1440 ) {
return 'about ' . round(floatval($distanceInMinutes) / 60.0) . ' hours';
}
if ( $distanceInMinutes < 2880 ) {
return '1 day';
}
if ( $distanceInMinutes < 43200 ) {
return 'about ' . round(floatval($distanceInMinutes) / 1440) . ' days';
}
if ( $distanceInMinutes < 86400 ) {
return 'about 1 month';
}
if ( $distanceInMinutes < 525600 ) {
return round(floatval($distanceInMinutes) / 43200) . ' months';
}
if ( $distanceInMinutes < 1051199 ) {
return 'about 1 year';
}

return 'over ' . round(floatval($distanceInMinutes) / 525600) . ' years';
echo $distanceInSeconds;
distanceofTimeInWords(2003,2005);
}

?>

Pororo 11:35am Sep 4
hello Arup Debnath, may i know how to use this function? what value $fromTime should be? sorry.. hehe.. i'm so lazy to read u'r function.

Slamet Aprilianto 11:41am Sep 4
remove these lines
echo $distanceInSeconds;
distanceofTimeInWords(2003,2005);
then type (outside the function)
echo distanceofTimeInWords(2003,2005);

may be that's what you want..

Pororo 11:42am Sep 4
ok. also try to read this:
http://www.mdj.us/web-development/php-programming/another-variation-on-the-time-ago-php-function-use-mysqls-datetime-field-type/

Arup Debnath 11:43am Sep 4
dude it worked!! thanks... Slamet Aprilianto

Slamet Aprilianto 11:45am Sep 4
youre welcome..

Arup Debnath 11:46am Sep 4
but there is a problem,, it echoed out "less than a minute".. ???

Arup Debnath 11:46am Sep 4
thanks Pororo

Slamet Aprilianto 12:03pm Sep 4
because that is what ur code said,
$distanceInSeconds = round(abs(2005 - 2003)) = 2
$distanceInMinutes = round(abs(2/60)) = round(0.03) = 0

Arup Debnath 12:12pm Sep 4
oh i missed that... k thanks...

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar