LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-16-2021, 06:09 PM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
A matter of time


I am used to using shared webhosts.

They usually have the server time on UTC, which is 8 hours behind my time here in China.

So when I set timers with PHP, I always need to subtract 28800 seconds to get the right time on the server.

Now I am trying to use a cloud server, which is located in Chengdu, China, I believe.

The server is on normal Chinese time, not UTC.

Will this affect anything in anyway??
 
Old 11-16-2021, 06:58 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Maybe, The system clock is always UTC. The default time that is displayed via the date command is whatever timezone is configured.

What default timezone PHP uses is defined in the php.ini file date.timezone configuration setting. If you can not modify the php.ini file you can set the time zone in your actual php script using the date_default_timezone_set function.
 
Old 11-16-2021, 08:42 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
If you were converting times away from UTC and storing the "corrected" values, then yes you're in trouble. I remember explicitly telling you not to do that.
 
1 members found this post helpful.
Old 11-16-2021, 08:51 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
You might want to take a look at the timedatectl command. It's output may cast some light on the situation.

I think it's a systemd-related command, as I had not heard of it until this thread caught my interest, but the odds are pretty good that your shared host uses systemd.

Last edited by frankbell; 11-16-2021 at 08:53 PM. Reason: clarity
 
Old 11-17-2021, 01:10 AM   #5
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
Thanks for your replies.

I wasn't complaining in any way.

I am quite happy to have the server time on Chinese normal time, saves me arithmetic, which I am not good at!

I didn't set or unset anything, that's how the Ubuntu server installation was when I got it.

I just wondered it there could be any negative consequences at all.
 
Old 11-17-2021, 02:01 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by Pedroski View Post
I just wondered it there could be any negative consequences at all.
That is actually depends on the software you use. If those can handle it properly. (I don't mean perl, php, python or whatever tools themselves, but the code running ....)
 
Old 11-17-2021, 05:19 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Usually the default timezone in the php.ini file is left blank blank which defaults to the timezone of the server. Since that is what you want there isn't a problem.

From personal experience I always get a postgresql warning that I should specifically set the timezone and not leave it a default.
 
Old 11-18-2021, 12:58 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by Pedroski View Post
I am quite happy to have the server time on Chinese normal time, saves me arithmetic, which I am not good at!
That's what correctly setting up your system's (and PHP's) locale is there for!
 
Old 11-18-2021, 08:51 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Typically, everyone sets their server hardware clocks to UTC. Then, they set the time-zone according to where the server is located. This gives them binary clock-values that are directly comparable anywhere in the world, while offering time displays that are correct for the location. It's very unusual that a Chinese server operator would set the hardware clock to local time.
 
Old 11-18-2021, 09:09 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
I think I know what you were try to write but the hardware clock and system clock are technically independent of each other. The system clock is always UTC but would say that most set a server's timezone to UTC versus local time.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: It was only a matter of time.... LXer Syndicated Linux News 0 03-14-2019 11:27 PM
"It WAS an Inside Job!" (It's only a short matter of time, folks ...) sundialsvcs General 15 02-16-2015 06:47 PM
Problem with logrotate and size - rotates every time, no matter what size set mav1c Red Hat 3 08-05-2013 01:30 PM
how to understand user time, sys time, wait time, idle time of CPU guixingyi Linux - Server 1 08-24-2010 10:10 AM
LXer: Linux desktop domination "just a matter of time" LXer Syndicated Linux News 0 11-18-2006 06:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration