Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi!
I'm looking at the "man Date" but I can't understand the syntax.
My system timezone is correct, at -0300. When I run the "Date" command for a given value, the timezone changes.
QUESTION: how do I adjust the date and time in this example:
February 1, 2010, at time of 13hours 14minutes 15seconds, with timezone at -0300
I am running this command and it is displaying an invalid date error:
date +%Y%m%d%H%M%S%z -s "20100201131415-0300"
Well ... I KNOW that it works sans the time zone term, I just never used the time zone in this command since the time zone is already all set in my system, or I can change it also using /etc/timezone
EDIT: I see scasey's response and perhaps there should be that space before the timezone. As I say, never did anything with the timezone in this command.
Well ... I KNOW that it works sans the time zone term, I just never used the time zone in this command since the time zone is already all set in my system, or I can change it also using /etc/timezone
EDIT: I see scasey's response and perhaps there should be that space before the timezone. As I say, never did anything with the timezone in this command.
info date says to set the TZ environment variable, then execute date. When I execute the command I posted (with -d, not -s), it doesn't change the timezone from my -0700 (MST) to -0300. I've never needed to use the time zone in the date command, either.
One online reference says: The --date=STRING is a mostly free format human readable date string
such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
even "next Thursday".
First of all: the "date" command is very confusing!!
Quote:
But I shudder to think what happens to your system if you change the date to be more than 7 years ago...
There was no problem with the system. It was just an example ...
The below command works partially because it didn't change the system timezone, but it works to change date and time. With the "-d" option also worked partially.
Code:
date -s "2010-02-01 13:14:15 -0300"
Regarding the timezone problem, I understood what is happening at this moment. In this case the system identified as daylight saving time in the place where I live. I don't know how to fix it, but I don't think it'll make any difference where I'm going to use it.
I'm building a small program in NodeJS to fix the system date and time and for this I use the "exec" function from "child_process" of the Node. If it has a way to run in bash as well, it might work fine. So I'm using the "date" command.
There's a neat little command line utility called "tzselect" that you can use to set the time zone. It quite easy to use and many distros include it out of the box.
What works for me is to use the date command to set the time, then use the hwclock to set the hardware clock fomr the system time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.