ajetrumpet Posted October 14, 2019 Share Posted October 14, 2019 (edited) I apologizing for bothering the expert here again, but I've run into another issue. I am using the following code because I can't change the default timezone on my shared hosting plan: $time = date("h:i A", strtotime("+19 hours")); there are few issues with this. if I just use: date("h:i: A") the time prints as 7 hours earlier than my timezone, and currently it shows 1:09 AM and it appears in the database as "01:09:00". if I use the code above, the time prints out as "08:09 PM", but it is inserted into the database as "08:09:00". Shouldn't it read "20:09:00" instead? and why isn't the time being inserted into the database with the "PM" suffix on it like it appears in the printout? the "time" field in my database is set to type TIME. thanks. Edited October 14, 2019 by ajetrumpet Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 14, 2019 Share Posted October 14, 2019 Does date_default_timezone_set() not work? Quote Link to comment Share on other sites More sharing options...
ajetrumpet Posted October 14, 2019 Author Share Posted October 14, 2019 no it doesn't. nor does modifying the .htaccess file. i also tried that. but godaddy specifically told me the default timezone can't be changed. Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 14, 2019 Share Posted October 14, 2019 OK - sorry. A little closer look at the question you're actually asking. first off, date's format 'h' is a 12-hour format with leading 0, so it won't read as '20'. And MySQL TIME type doesn't include AM/PM. Try changing the date format to 'H:i:s'. 1 Quote Link to comment Share on other sites More sharing options...
ajetrumpet Posted October 14, 2019 Author Share Posted October 14, 2019 that works fine. i appreciate it. Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 14, 2019 Share Posted October 14, 2019 Glad it helped! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.