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

  • SEARCH
  • Home
  • 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 8322685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:28:18+00:00 2026-06-08T23:28:18+00:00

I want to store the date and time that a user performs an action

  • 0

I want to store the date and time that a user performs an action on my website into a MySQL database. I’d like to be able to do the following with ease:

  • Store the date and time as one field in the database
  • Use a built in PHP or MySQL function to generate the date-time of the action
  • Store the date-time based on my server’s time, and not worry about user timezones.
  • Order By the date-time field when I query MySQL
  • Later, display the date-time in many different formats using built in PHP methods

Here are my questions:

  • What data type should I use in MySQL ( eg. timestamp, datetime … )?
  • What method should I use to generate the date-time ( eg. MySQL’s now(), PHP’s date() … )?
  • What PHP method should I later use to format the date-time in various pretty ways ( eg. 23/4/2012, 5pm on Monday, July 2012 … )?
  • 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-08T23:28:19+00:00Added an answer on June 8, 2026 at 11:28 pm

    I would store it as a datetime, not a timestamp.

    I normally use the PHP date function and that way if you ever want to store the time relative to the user’s timezone you can simply change the timezone based off the user’s settings.

    When you pull it out of the database, use strtotime() to convert it, then you can use all the date() features to display it however you want. Example:

    echo date('F j, Y',strtotime($db_datetime)); //Displays as 'March 5, 2012'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I store a date/time in my database that is UTC. I'm working to add
I want to store the current date & time which can be get by
I've got two times that need to be stored into a database. The time
I want the user to enter an appointment date and time and send him
I store current time in database each time application starts by user. Calendar c
I use MySQL DATETIME column to store date & time. Dates are in UTC.
I am a new developer on Android and I want store user data in
I want to store the password used for signing in a financial application that
I want to store a user setting(language). so i can get the corresponding resources
I want to store a .NET object into Azure Blob Storage. Currently I serialize

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.