FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution. It is used to power modern servers, desktops, and embedded platforms.
In FreeBSD date and time can be displayed using the date command. This article describes how to set date and time using date command in FreeBSD.
How to display the current date and time
To display the current date and time use the following command in your terminal –
date
How to set date and time in FreeBSD
To modify systems date or time you need to be a superuser or root user.
Change the date and time in a single command
If you want to change both date and time then you should use the date command in the given format –
date yymmddHHMM
where,
yy – Year in two-digits
mm- Month of the year (1-12)
dd- Day of the month(1-31)
HH- hours(0-23)
MM- Minutes (0-59)
For example to set today date July 13 2020, 13:07:00 you should use –
date 2007131307
Set the time only
To change the time without changing the date, you should use the date command in the given format –
date HHMM
For example to set time 13:07:00 we will use –
date 1307
How to change the timezone
For setting the local time zone tzsetup command is used in freebsd. This command reads the database of timezone information, the content of the database is indexed by
/usr/share/zoneinfo/zone.tab
Now to change the time zone execute the following command in your terminal –
tzsetup
This will open the terminal menu to select the time zone. Look in the image below –
First, choose your timezone area and then select your country or region and press ok. This will open another confirmation window if abbreviation looks reasonable then press enter. Your time zone is changed successfully.
Now run the date command –
date
As you can see that the time zone is changed from UTC to IST(Indian Standard Time).
Ok, that’s all for now. If you want to say something on this topic you can write to us in the comments below.