Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: time variable

  1. #1
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default time variable

    i have this code:
    PHP Code:
    strftime("%d/%m/%y %H:%M",time()) 
    the time() part returns the time for America (i think thats the server time).
    Could anybody please provide a way of making the time() part return the time for london?


    thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    In PHP5:
    Code:
    date_create('now', new DateTimeZone('BST'))->format("d-m-Y G:i");
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    could it be in: PHP, PHP3, and PHTML scripts?

    as the sever only supports them...
    Last edited by lankinator; 07-16-2007 at 05:57 AM.

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    As long as the server has PHP 5+ installed, it can be whatever extension you want to make it (as long as it is parsed as a PHP script).
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    could it be in: PHP, PHP3, and PHTML scripts?

    as the sever only supports them...

  6. #6
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    So basically you're saying PHP5 is not installed on your server...
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's fine, the .php extension will handle it (it's probably PHP4).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by lankinator View Post
    could it be in: PHP, PHP3, and PHTML scripts?
    The extension of a PHP script doesn't in any way define the version of PHP in use: PHP 5 can quite easily parse a file ending ".php3".

    If you want to be useful, actually state what version of PHP your host uses. This information is normally available in the response headers. This can also be found in the document generated by the phpinfo function, and from the phpversion function.
    Mike

  9. #9
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    as the sever only supports them...
    i stated there that it only has php3, php, phtml installed

    twey, i get the following error:
    [b]Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in \\192.168.0.16\webfiles\files\2007-1\1253297\user_pages\user.php on line 1[/b[

  10. #10
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by lankinator View Post
    i stated there that it only has php3, php, phtml installed
    No, you stated what file extensions will effect parsing as PHP on your server. That has no bearing on what version of PHP is installed.

    twey, i get the following error:
    Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in \\192.168.0.16\webfiles\files\2007-1\1253297\user_pages\user.php on line 1
    This is due to the failings of PHP as a language: the DateTime object needs to be assigned to a variable before one of its methods can be called.

    PHP Code:
    $date = new DateTime('now', new DateTimeZone('BST'));
    echo 
    $date->format('d-m-Y G:i'); 
    Mike

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
  •