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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:52:12+00:00 2026-06-03T18:52:12+00:00

I am creating this post, to get confirmation that i am understanding the process

  • 0

I am creating this post, to get confirmation that i am understanding the process correctly, and also to get feedback on a few minor details on solving the issue of post times being displayed and stored correctly for users in various time-zones.

Storing the time

First step is getting the users timezone as a GMT offset format using a javascript function, and storing it in a session variable. For example, the $timezone variable will store GMT -4

$timezone=$_SESSION['time'];

Next, Once i have my users timezone. When the user makes a post, I store the post time in mysql database, I will need to store it as a UTC format. How do i do this? Currently when I store the time data. it is in the following way. My stamp field is datetime format, and i would like to leave it as such if possible.

INSERT INTO posts (stamp) VALUES (now())

What function do i use instead of now() to get the UTC format which will then be inserted into my database? I assume that I need to use a php function which will use the $timezone to produce the UTC date.

Displaying the time

Next, Once the UTC date is stored in the db. I need to display the data to the user based on the $timezone variable we set.

So when I display the time, I currently do

echo date('F d', strtotime($list1['stamp']));

Once i have stored the data as UTC time, this will display the UTC time, but i need to show the user the UTC offset for their timezone, so I will need to convert $list['stamp'] in UTC time to a the users timezone using $timezone. What function do i user for this?

tl:dr
This should be all I need to make this work. let me know if you see any suggestions, or items that i have not accounted for, and if you know what functions I need to use to convert the time to UTC to store in the database, and what function to use to convert the UTC time to display user, using the $timezone variable.

  • 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-03T18:52:15+00:00Added an answer on June 3, 2026 at 6:52 pm

    For inserting UTC time into the database:

    INSERT INTO posts (stamp) VALUES (UTC_DATE())
    

    UPDATE: This will only insert the YYYY-MM-DD into your database. If you need time as well, then use:

    INSERT INTO posts (stamp) VALUES (UTC_TIMESTAMP())
    

    Then for printing the date according to timezone:

    $date = date_create($list1['stamp'], timezone_open($timezone)); //$timezone='Pacific/Nauru';
    echo date_format($date, 'F d');
    

    That should help get you started. Learn more about PHP’s DateTime Class for Object Oriented Methods, and cleaner programming in general.

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

Sidebar

Related Questions

I hope that in this post, I can get people's opinions on best practices
I've been reading this post Creating a login form in CodeIgniter based on Ion
Does anybody recognize this error? org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory': Post-processing of
How can I have it so Visual Studio doesn't keep re-creating this folder that
Note: I found this Creating a Word Doc in C#.NET , but that is
I am creating a new item using the Core Service in this post .
I've heard that there might be a possibility to post GET query and pass
This post is about installing XLAM's without creating links. (Everyone hates links). Consider the
i was wondering what is the better way of creating a get/post actions set
I have a query where I need to get post + every tag that

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.