Results 1 to 9 of 9

Thread: php help in time

  1. #1
    Join Date
    Mar 2007
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy php help in time

    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

  2. #2
    Join Date
    May 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Just a guess, never tried this:

    $NOW ( ) + 900;

    ?

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    $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().
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    May 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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;

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    May 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yea, i understand what your saying. Thanks for the help. Even though it wasnt my thread i have learnt a lot from you

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by sukanya.paul View Post
    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?

    Quote Originally Posted by djr33 View Post
    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.

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •