PDA

View Full Version : php help in time



sukanya.paul
05-18-2007, 03:58 AM
hi..i need the current time according to my system time..i usually get this as the GMT but i want in IST..if i assign tht as $now. then i want the time after 15mins(900 sec) as $endtime.
how do i do tht?
help needed urgently
thanks in advance

MrSheen
05-23-2007, 08:52 AM
Just a guess, never tried this:

$NOW ( ) + 900;

?

djr33
05-23-2007, 09:14 AM
$endtime = time()+900;

That's the more standard way, i'd think.

Above uses now, which I think is a synonym for time and both a dollar sign and (), meaning it's a variable and a function? Pretty sure this is invalid.
Perhaps this is syntax borrowed from another language.
Also note that in PHP case matters, so NOW is not the same as now, which I believe is the function in question: now().

MrSheen
05-23-2007, 10:39 AM
Opps my error.

Im sure the php now function is NOW ( ).. or is that just in mysql queries?

Yea, it was meant to be a function, i got side tracked and was meant to type

$time = NOW ( ) + 900;

djr33
05-23-2007, 10:53 AM
I think that would apply to mysql.

Again, the function in question is now(), if anything, in lowercase, since PHP functions are case sensitive.

The official function for the current timecode is simply time(), and this is standard.

I'm also not used to placing the parentheses apart from the word, though this may be valid, but I wouldn't know without some testing.


EDIT: http://www.php.net/manual/en/function.time.php
There is no mention of the now function in the documentation nor search function. I think this must just be mysql.

MrSheen
05-23-2007, 10:58 AM
Yea, i understand what your saying. Thanks for the help. Even though it wasnt my thread i have learnt a lot from you :)

djr33
05-23-2007, 11:00 AM
Sure. And remember that php.net is very easy to use to check any function. Just type it in the search bar and look it up, and it'll give example situations with demo scripts so you can know how to apply it to your page, at least the basics. With that to start you off, the rest is just putting various functions together.

blm126
05-23-2007, 09:44 PM
i want in IST..if i assign tht as $now. then i want the time after 15mins(900 sec) as $endtime.
I'm confused as to what you want. Do you just want the time formatted to INdian Standard Time?



Above uses now, which I think is a synonym for time and both a dollar sign and (), meaning it's a variable and a function? Pretty sure this is invalid.

Perfectly valid. PHP will take the contents of the variable and use it as the function name.


Perhaps this is syntax borrowed from another language.

See above.


Also note that in PHP case matters, so NOW is not the same as now, which I believe is the function in question: now().
This is just wrong. PHP variable names are case-sensitive. However, function names are case-insensitive. NOW() and now() are equivalent. It is just considered good form to use the correct case.

djr33
05-24-2007, 02:25 AM
Perfectly valid. PHP will take the contents of the variable and use it as the function name.I wasn't aware of that. That's good to know. However, in this case, there was no place where $now was set to the value of 'time'.

As for the case, wasn't aware of that either. Alright.

Still, now() doesn't do anything.