How to get sys date/time in GMT-5 in PHP

Posted on 2007-07-20
Last Modified: 2008-01-09

I want to return a string in that format:
(2007-July-20 10:30:00)

I don't know in which time zone the server is set but I want the result to be in GMT-5 time. How do I do this?
Question by:mychel_normandeau
    LVL 2

    Expert Comment

    One way is this:

    $dt = date('Y-F-d H:i:s', gmdate() - 3600 * 5);
    LVL 2

    Accepted Solution

    print date('Y-M-d h:i:s');

    If you want a timezone of some specific city then you can use like putenv('TZ=Asia/Calcutta') also.

    Author Comment

    If I use
    date('Y-M-d h:i:s', time() - 18000)
    would it work on any server config?

    Doest time() gives the current GMT0 unix timestamp?
    LVL 2

    Assisted Solution

    time() defaults to current local time.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now