Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    get current time question

    Hi,

    I just would like to know how to produce the current time like

    Code:
     8:30 pm
    I was having trouble using the date function like this

    Code:
     date("F j, Y,  g :i a ")
    for it produces a time under a different (default) timezone.

    any help please...thanks
    Last edited by Inigoesdr; 12-19-2010 at 11:57 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    for it produces a time under a different (default) timezone.
    Set your servers default timezone first.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    You can do as abduraooft suggests or you can simply do math on the time() function's timestamp result to add/subtract the appropriate amount of time before running the date() function on that timestamp - which you might need/want to do for adjustments from GMT (for example).
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #4
    New Coder
    Join Date
    Dec 2010
    Location
    Orlando, FL
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by codebyte View Post
    Hi,

    I just would like to know how to produce the current time like

    Code:
     8:30 pm
    I was having trouble using the date function like this

    Code:
     date("F j, Y,  g :i a ")
    for it produces a time under a different (default) timezone.

    any help please...thanks

    All you need to do is set the timezone, use the reference that abduraooft gave you.

    If you need to find out what your current time zone is use:
    http://www.php.net/manual/en/functio...mezone-get.php

    And here's the list of supported timezones:
    http://www.php.net/manual/en/timezones.php

    That should fix your issue easily

  • #5
    New Coder
    Join Date
    Jan 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    I actually got the answer before I returned back to this post and saw the replies..

    I read the php manual for time manipulations and just adjusted the timezone

    Code:
    date_default_timezone_set()
    to fit the timezone I am in..

    Thanks anyways for your replies...



  •  

    Posting Permissions

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