Skip to main content

date command in Linux with examples

 




Date command is used to display the system date and time. date command is also used to set date and time of the system. By default the date command displays the date in the time zone on which unix/linux operating system is configured.You must be the super-user (root) to change the date and time. 



Syntax: 

date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]


Options with Examples 
1: date (no option) : With no options, the date command displays the current date and time, including the abbreviated day name, abbreviated month name, day of the month, the time separated by colons, the time zone name, and the year. 

$date
Output: 
Tue Oct 10 22:55:01 PDT 2017


2:-u Option: Displays the time in GMT(Greenwich Mean Time)/UTC(Coordinated Universal Time )time zone. 

Command: 
$date -u
Output :
Wed Oct 11 06:11:31 UTC 2017


3: –date or -d Option: Displays the given date string in the format of date. But this will not affect the system’s actual date and time value.Rather it uses the date and time given in the form of string. 
Syntax: 
 $date --date=" string "

Command: 
$date --date="2/02/2010"
$date --date="Feb 2 2010"
Output: 
Tue Feb  2 00:00:00 PST 2010
Tue Feb  2 00:00:00 PST 2010


4:Using –date option for displaying future date: 
 

Date and time of upcoming particular week day. 

Command: 
$date --date="next tue"
Output: 
Tue Oct 17 00:00:00 PDT 2017

Date and time after two days. 

Command: 
$date --date="2 day"
Output: 
Fri Oct 13 00:05:52 PDT 2017

Date and time of next day. 

Command: 
$date --date="tomorrow"
Output: 
Thu Oct 12 00:08:47 PDT 2017


Comments

Popular posts from this blog

Run any GUI software in docker container

 

Vivo Announces Android 11-Based Funtouch OS 11 Beta Update Schedule for India

Vivo has announced the rollout schedule for the beta version of its Android 11-based Funtouch OS 11 in India that will go on till June. The Vivo V20 debuted with the stable version of Android 11 with Funtouch OS 11 in October, and the Vivo X50 Pro started receiving the update last month, but the company was yet to announce the schedule for its older models. The update schedule has devices ranging from the budget segment to the premium segment. The company took to Twitter to reveal its Android 11-based Funtouch OS 11 beta rollout plan. Vivo clarified that users will receive the update on a batch-by-batch basis. The Vivo V20 and the Vivo V20 Pro are already running on the latest OS. The Vivo X50 Pro, too, started receiving the update last month, Vivo said. The Vivo V19 and the Vivo X50₹ 34,990 will start receiving the Android 11-based Funtouch OS 11 beta version update at the end of January 2021, while Vivo V17, Vivo V17 Pro₹ 27,375, Vivo V15 Pro, and Vivo S1 will start receiving the upd...

Introduction Types of Computer Network

  What is a Computer Network? Computer networks is bunch of computers connected through optical cables, wires and fibers so that it interacts with each other through networks. The goal is to share the content and the information among the system of same network or other. In computer networks there are different types of networks that shares the information among each other they maybe simplex or complex ones.