Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3330688
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:30:53+00:00 2026-05-17T23:30:53+00:00

The server my PHP script is running on is set to UTC. I can’t

  • 0

The server my PHP script is running on is set to UTC. I can’t seem to figure out a way to set all dates to the browser’s timezone. All dates displayed are formatted using PHP’s date() function.

I know that via JavaScript’s getTimezoneOffset() function, I can get the browser’s current UTC offset (-4, in my case). How can I tell PHP to use this offset? I can use date_default_timezone_set(), but how do I convert an offset, say -4, to a time zone string, say America/New_York?

Note: The server is running PHP 5.1.6 (with no DateTime class) and I am using CodeIgniter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:30:53+00:00Added an answer on May 17, 2026 at 11:30 pm

    As per the comment above- you could use a cookie…:

    Javascript:

    var today = new Date();
    
    function SetCookie(cookieName,cookieValue,nDays) {
     var expire = new Date();
     if (nDays==null || nDays==0) nDays=1;
     expire.setTime(today.getTime() + 3600000*24*nDays);
     document.cookie = cookieName+"="+escape(cookieValue)
                     + ";expires="+expire.toGMTString();
    }
    
    SetCookie("datecookie", today, 30);
    
    window.location.href=window.location.href
    

    PHP:

    echo date("m d Y", strtotime($_COOKIE['datecookie']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script (running on a Linux server) that ouputs the names
I'm running PHP 5.2.6 on a Windows Server 2003 Enterprise box. IIS is set
I have a php script http://example.com/myapp/myscript.php running on an Apache server. I call this
I have created a PHP-script to update a web server that is live inside
I have a simple php script on a server that's using fsockopen to connect
I have a php server that is running my domain name. For testing purposes
I have a PHP script which changes file permissions on my server using chmod.
I have a PHP server at home for development. It is running: Ubuntu 9.10
I' running a php script to insert events that I take from a CSV
For a recent project, I have a PHP script running as a CLI-based daemon.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.