We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

Tutorials

More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsOperating SystemsLinuxAdministration

How to change time in your VPS

Windows Cloud Server

Use the date command to display the current date and time or set the system date / time over ssh session. You can also run the date command from X terminal as root user.

This is useful if the Linux server time and/or date is wrong, and you need to set it to new values from the shell prompt.
You must login as root user to use date command.
Linux Set Date

Use the following syntax to set new data and time:
date –set=”STRING”

For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
# date -s “2 OCT 2006 18:00:00″
OR
# date –set=”2 OCT 2006 18:00:00”

You can also simplify format using following syntax:
# date +%Y%m%d -s “20081128”
Linux Set Time

To set time use the following syntax:
# date +%T -s “10:13:13”
Where,

* 10: Hour (hh)
* 13: Minute (mm)
* 30: Second (ss)

Use %p locale’s equivalent of either AM or PM, enter:
# date +%T%p -s “6:10:30AM”
# date +%T%p -s “12:10:30PM”

Brazil VPS
Rate this Tutorial:
2 Comments Leave a Comment
  1. Hasanen Albana

    Settings date using ‘date’ command on ubuntu vps always returns “operation not permitted”
    date -s “14:18”
    date: cannot set date: Operation not permitted

    Reply
    • Host1Plus Staff

      Hello Hasanen Albana,

      I would like you to inform, that you can’t change time on our Linux virtual private servers, however, what you can do is change timezone.

      Note: to change timezone, you need to be logged in as the root user or as a user with sudo privileges.

      To change your timezone execute the following commands:

      sudo apt-get install systemd-services
      timedatectl (to see what timezone your vps is using)
      timedatectl list-timezones (This command will list all available timezones for example – Europe/Madrid)

      Then just type in this command:

      timedatectl set-timezone [……] (Where [……] is your chosen timezone)

      Example: timedatectl set-timezone Europe/Madrid

      Now you should have changed your timezone, to check it, run timedatectl command again.

      Hope it helps, have a good day!

      Let me know if you stumble upon any other issues.

      Reply
Leave a Comment

Other (3)

Popular Keywords