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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:34:13+00:00 2026-05-27T15:34:13+00:00

I have a page where I get a date/time to insert into a MySQL

  • 0

I have a page where I get a date/time to insert into a MySQL database.

The timezone the server in is two hours ahead.

In my php.ini I have date.timezone = America/Los_Angeles

I noticed sometimes the time was off by two hours.

MySQL field is type datetime, not null (and I just notice I haven’t set default value)

I’m using Codeigniter, if that matters.

This is how I get the time to insert into the database:

$newData['time'] = $time = date("Y-m-d G:i:s");

I inserted a line of code after that to write the time to the error log.

log_message('error', "Date time is $time");

Why is the time changing like this? This portion of the log is from 2:00pm to 2:30pm local time.

This is all coming from a single page on my site in the span of 29 minutes.

110 ERROR - 2011-12-20 14:00:57 --> Date time is 2011-12-20 14:00:57
111 ERROR - 2011-12-20 14:01:38 --> Date time is 2011-12-20 14:01:38
112 ERROR - 2011-12-20 14:01:57 --> Date time is 2011-12-20 14:01:57
113 ERROR - 2011-12-20 16:02:19 --> Date time is 2011-12-20 16:02:19
114 ERROR - 2011-12-20 16:02:28 --> Date time is 2011-12-20 16:02:28
115 ERROR - 2011-12-20 14:03:26 --> Date time is 2011-12-20 14:03:26
116 ERROR - 2011-12-20 14:03:32 --> Date time is 2011-12-20 14:03:32
117 ERROR - 2011-12-20 14:03:46 --> Date time is 2011-12-20 14:03:46
118 ERROR - 2011-12-20 14:04:43 --> Date time is 2011-12-20 14:04:43
119 ERROR - 2011-12-20 14:04:53 --> Date time is 2011-12-20 14:04:53
120 ERROR - 2011-12-20 14:04:58 --> Date time is 2011-12-20 14:04:58
121 ERROR - 2011-12-20 14:05:03 --> Date time is 2011-12-20 14:05:03
122 ERROR - 2011-12-20 16:07:05 --> Date time is 2011-12-20 16:07:05
123 ERROR - 2011-12-20 16:07:25 --> Date time is 2011-12-20 16:07:25
124 ERROR - 2011-12-20 16:07:54 --> Date time is 2011-12-20 16:07:54
125 ERROR - 2011-12-20 16:08:05 --> Date time is 2011-12-20 16:08:05
126 ERROR - 2011-12-20 16:08:15 --> Date time is 2011-12-20 16:08:15
127 ERROR - 2011-12-20 16:09:04 --> Date time is 2011-12-20 16:09:04
128 ERROR - 2011-12-20 16:09:14 --> Date time is 2011-12-20 16:09:14
129 ERROR - 2011-12-20 16:09:44 --> Date time is 2011-12-20 16:09:44
130 ERROR - 2011-12-20 16:10:08 --> Date time is 2011-12-20 16:10:08
131 ERROR - 2011-12-20 16:10:27 --> Date time is 2011-12-20 16:10:27
132 ERROR - 2011-12-20 14:12:16 --> Date time is 2011-12-20 14:12:16
133 ERROR - 2011-12-20 14:15:30 --> Date time is 2011-12-20 14:15:30
134 ERROR - 2011-12-20 14:16:20 --> Date time is 2011-12-20 14:16:20
135 ERROR - 2011-12-20 14:17:55 --> Date time is 2011-12-20 14:17:55
136 ERROR - 2011-12-20 14:18:51 --> Date time is 2011-12-20 14:18:51
137 ERROR - 2011-12-20 14:19:16 --> Date time is 2011-12-20 14:19:16
138 ERROR - 2011-12-20 14:20:08 --> Date time is 2011-12-20 14:20:08
139 ERROR - 2011-12-20 14:27:29 --> Date time is 2011-12-20 14:27:29
140 ERROR - 2011-12-20 14:29:31 --> Date time is 2011-12-20 14:29:31
141 ERROR - 2011-12-20 14:29:55 --> Date time is 2011-12-20 14:29:55

Can anyone shed some light on this for me?

Thanks,

Mark

  • 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-27T15:34:14+00:00Added an answer on May 27, 2026 at 3:34 pm

    My guess would be an issue with your system time itself like meouw said, or as John B mentioned, the PHP timezone might be getting overwritten somewhere in your CI config.

    Assuming you’re running a linux/gnu box, you should change your error logging to something like this:

    log_message('error', "PHP time is $time, System time is ".exec('date'));

    Which should at least let you know if the issue is with your system time or PHP’s time

    (Note: You’re looking for the system time jumping hours apart like your PHP time does, system time being a second or two different from your PHP time is normal)

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

Sidebar

Related Questions

I have a php page which has a chart, a date picker(calendar) and a
I'm using time() to store date in the database. I have some kind of
i'have a js client with JQuery, this js call a page (GET HTTP) and
I have forms in my page a get and a post and i want
I have a page called ..hi i get this error when visiting the page.
I have a page that is under SSL. However, in IE6, I get a
I have a problem with a page where I am trying to get colorbox
i have put fckeditor in jsp page. I want to get the value whatever
I have the following question: It is easy to insert an oBject in database
I have asked aqbout timezones and date/time before but this is a more specific

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.