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 8766817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:38:42+00:00 2026-06-13T16:38:42+00:00

I have a page that shows future events along with the date (server time).

  • 0

I have a page that shows future events along with the date (server time).
I need some method to display the date in user time.

Example:
Oct, 26 13:48:23 (server)
Oct, 26 14:48:23 (user time (UTC +1)) -> event info

What I have so far:

<?php
    $sql=mysql_query("SELECT * FROM table") or die("Come back later");
    while($row=mysql_fetch_array($sql)) {
        echo date('M, d H:i:s', strtotime ($row['date'])).' -> '.$row['info'];
    }
?>

With the diffence I want to detect user timezone.

Thank you.

EDIT
I know I should not be using mysql_*

  • 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-06-13T16:38:43+00:00Added an answer on June 13, 2026 at 4:38 pm

    If you’re ok with doing the conversion to the user’s time zone in JavaScript, you could do the following:

    PHP

    <?php
        $sql=mysql_query("SELECT * FROM table") or die("Come back later");
        while($row=mysql_fetch_array($sql)) {
            echo '<span class="date">' . date('M, d H:i:s', strtotime ($row['date'])) . ' UTC</span> -> '.$row['info'];
        }
    ?>
    

    JavaScript (With jQuery for Readability)

    $(function(){
        $('.date').each(function(){
            var $this = $(this);
    
            // Parse the date string (the format you've given will 
            // work, and the added UTC above will give JavaScript 
            // some context)
            var dateVal = new Date($this.text());
    
            // JavaScript will convert it to the user's timezone when 
            // stringifying it (helped by the server timezone specified
            // in the PHP.
            $this.text(dateVal.toString()); 
        });
    });
    

    If you want to render the dates in the format: Oct, 26 13:48:23, you could do this:

    var dateString = dateVal.toLocaleString();
    var parts = /^\w+ (\w+ \d{1,2}) \d{4} (\d{2}:\d{2}:\d{2})/.exec(dateString);
    dateString = parts[1] + ' ' + parts[2];
    

    Then use $this.text(dateString); to inject it into the dom.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MFMailViewController that shows what the user answered on the previous page.
So I have a loop that runs perfect for events and only shows future
I have a page that shows statistics for users, this cannot be cached because
I have a work page that shows all projects. I am using a taxonomy
I have a page ItemList that shows a list of items using div's. After
I have a client page where I have I the following that shows up
I have a Drupal 7 installation that shows the default front page. Published pages/nodes
I have this line below that shows a link to go the next page
I have a page that lets the user edit the content of the page
I have a page that shows 3 drop-down selectors on the page. I also

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.