I have this:
when $size = 0.2365489Code:$size = @filesize($path); $size = $size/1024; $size = // wich function?
the output has to be this: 0.24
wich function do I need?
| SitePoint Sponsor |
I have this:
when $size = 0.2365489Code:$size = @filesize($path); $size = $size/1024; $size = // wich function?
the output has to be this: 0.24
wich function do I need?
Two choices:
1) Use printf() to format the number when it is printed out
http://www.php.net/manual/en/function.printf.php
printf( %.2f, $size );
or
2) use round() to actually round the value
http://www.php.net/manual/en/function.round.php
$size = round($size, 2);
thanx, another question:
my server time is now 7.27 in the morning
at home it is now 00.27 in the moring,
i tried to fix it like this:
But this doesn't work...Code:gmdate("d M Y H:i",time() - 25200);





What do you mean it doesn't work?
It returns a string, so it should be:
echo gmdate("d M Y H:i",time() - 25200);
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy





How about:
PHP Code:print date("d M Y H:i", mktime(date("H") - 7,0,0,date("m"),date("d"),date("Y")));
Please don't PM me with questions.
Use the forums, that is what they are here for.
Freddydoesphp's output: 02 Mar 2001 05:49 (here it is 0:49)
SonNguyen' output: 02 Mar 2001 05:49 (here it is 0:49)
Both codes works, but they have a wrong output
oh, freakysid,
your printf( %.2f, $size );
gives the following error:
Warning: printf(): too few arguments in /myhosts/www/pubhtmldir
your $size = round($size, 2);
gives the following error:
Warning: Wrong parameter count for round() in /myhost/www/pubhtml/index.php on line 89
eeeeehhhhhhh, I'm in trouble![]()



i don't know about time... but as for the rounding...
that should work... I just tried it!PHP Code:$size = round ($size, 3);
Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.
Exbabylon- Professional Internet Services





Okay use this for the rounding
PHP Code:$size = number_format($size, 2);
For the date offset
Do you want to make your home time the same as the server time?
PHP Code:print date("d M Y H:i", mktime(date("H") + 7,0,0,date("m"),date("d"),date("Y")));
Please don't PM me with questions.
Use the forums, that is what they are here for.
he,he - I'm pretty ignorant about printf
As for round() wrong number of parameters. My code was for php4. Are u using php3?
Freakysid, I'm sure I have PHP4 installed!
so...
I'll try your stuff tonight!
And FreddyNo, I just want to turn back server time 7 hoursDo you want to make your home time the same as the server time?![]()





One thing, you called gmdate -> GMT date, so your call will return GMT-7 and not servertime -7
use this:
echo date("d M Y H:i",time() - 25200);
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Yeah, that works fine!
I've got the solution for my first problem nownow the second
round a number off...





Hmm... You must be doing something different than everyone else, because I just did these two and they both work exactly as shown below.
prints 3434.43PHP Code:<?
$num = 3434.42635675367;
print round($num, 2);
?>
AND
prints 3,434.43PHP Code:<?
$num = 3434.42635675367;
print number_format($num, 2);
?>
Please don't PM me with questions.
Use the forums, that is what they are here for.
thnx thnx thnx, everything works fine now, except:
this:
when I echo $time, there nothing printed...PHP Code:$time = @date("d M Y H:i",time() - 25200, filemtime($path));





What is with the three args for the date function, it only takes two, the format to disalpy the date and time source. YOu have an extra one in there, the filemtime(*) what purpose is to serve? try taking the @ off to see what error you are getting
Please don't PM me with questions.
Use the forums, that is what they are here for.
well, normally it's this:
This function works! I'm using this to get upload date of a file (php ftp prog)PHP Code:$time = @date("d M Y H:i", filemtime($path));
But I want this time offset
So I tried this:
But this doesn't work...PHP Code:$time = @date("d M Y H:i",time() - 25200, filemtime($path));
Oh, I tried to leave the "@", but it's the same, when i print the $time, it's a blank field...





From the manual
So since filemtime() returns a unix timestamp you should be able to use for subtractubg 7 hours from itint filemtime (string filename)
Returns the time the file was last modified, or false in case of an error. The time is returned as a Unix timestamp
BTW What is with your other post the links got sorted by date see my reply.PHP Code:$time = date("d M Y H:i", filemtime($path) - 25200);
Please don't PM me with questions.
Use the forums, that is what they are here for.
For those on php3 the round function can be used to round a number to 2 decimal places as follows.
If you need 3 decimal places change the 100's to 1000's. It is crude but works on both php3 and php4.PHP Code:$num = 0.12345;
$num = $num*100; //out put is 12.345
$num=round($num); //rounds number to 12
$num=$num/100; //out put is 0.12
Marty H.
Everything is all right now!!!
Thank you very much!
I'm using this now:
for the date:
in stead of round(), i use this:PHP Code:$time = date("d M Y H:i",filemtime($path) - 25200);
up to my next threadPHP Code:printf ("%.2f",$size);
![]()
Bookmarks