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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:22:00+00:00 2026-05-28T04:22:00+00:00

I use mktime() to store all of my dates for everything in my database,

  • 0

I use mktime() to store all of my dates for everything in my database, and I have a script that goes through and returns dates for set amounts of times, this works fine for showing how long ago things were posted, however when I try to return the exact date/time it returns one hour ahead of time, so I’m wondering how to get the date to always return the correct date when the time gets changed for any daylight savings or anything.

Here’s basically what I use (cut down to only show small portion of it):

function time_stamp($session_time) 
{ 
    date_default_timezone_set("EST");

    $time_difference = time() - $session_time; 

    $seconds = $time_difference; 
    $minutes = round($time_difference / 60 );
    $hours = round($time_difference / 3600 ); 
    $days = round($time_difference / 86400 ); 
    $weeks = round($time_difference / 604800 ); 
    $months = round($time_difference / 2419200 ); 
    $years = round($time_difference / 29030400 );

    // Seconds
    if($seconds==0)
    {
         return $seconds." second ago";     //See this works fine, obviously
    }
        else if($seconds <=60&&$seconds>0)
    {
        return date('F jS \a\t g:ia ', $session_time+60*60); //it's when i use date()
                                                             //it doesn't
    }
  • 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-28T04:22:00+00:00Added an answer on May 28, 2026 at 4:22 am

    Simple solution…

    Add this one line in your php.ini file:

    date.timezone = "America/New_York"
    

    After doing this, there is no need for:

    date_default_timezone_set("EST");
    

    And using functions like:

    time();
    

    Or

    date();
    

    Shouldn’t be a problem.

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

Sidebar

Related Questions

I'm trying to use PHP to create a script that searches all the days
I have a DATETIME for an entry in my database that is upcoming. I
Suppose i know that today's day is monday. How do i use mktime() in
I have a bash script that builds a command based on a list of
I have a database that stores the time for me. I insert it from
I have a project that needs me to accept an input for when (during
I am writing a script to query dates 3 months ago. As I am
I'm all of a sudden getting the following error on a site that I've
I have some code that deletes some files based on time_t comparisons with the
I use this function to set a cookie for the entire domain name: setcookie(tuittingID,

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.