Manually set the time on an Ubuntu server

1. Check the current time

Before setting the time, check the current system time by running:

timedatectl

This will display information about your system’s time and time zone.

2. Set the time manually

To set the time manually, use the timedatectl command in the following format:

sudo timedatectl set-time "YYYY-MM-DD HH:MM:SS"

For example, to set the date and time to October 12, 2024, 19:30:00, you would run:

sudo timedatectl set-time "2024-10-12 19:30:00"

3. Disable automatic time synchronization (if needed)

If your server is using NTP (Network Time Protocol) for automatic time synchronization, you may need to disable it before setting the time manually. To do this, run:

sudo timedatectl set-ntp off

4. Verify the new time

After setting the time, you can verify it with:

timedatectl

This will show the updated time and any other related settings.