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

Detailed Analysis on Arduino UNO R3

Arduino UNO R3 Arduino Uno is a microcontroller board based on ATmega328P . It has 14 digital input/output pins 6 Analog pins a 16 MHz quartz crystal oscillator with USB connection ,a power jack , an ICSP(In-Circuit Serial programming) header and a reset button actually it has two reset buttons . Also Arduino uno has RX-0,TX-1 that is receiving and transmitting pins on board. Arduino uno contains  AREF pin which means Analogue-Reference IOREF pin this pin is provides a voltage  reference at which the microcontrller works 3-ground pins 3-Vcc pins Basically the purpose of creating an Arduino Uno is to Control the sensors and the actuators so that it can work accordingly the data which we provide with the help of software . Nowadays people using Arduino Uno in many fields it has very huge scope in  the field of  IOT(Internet Of Things). Also in my current project which is 2D-printer we have used Arduino Uno which sense the Data and according...

What are the differences between StaticJsonBuffer and DynamicJsonBuffer?

   StaticJsonBuffer ArduinoJson  uses preallocated memory to store the data and this is possible due to StaticJsonBuffer. If one has to use this library then firstly they should create t he StaticJsonBuffer just like: StaticJsonBuffer<200> jsonBuffer; then it creates an  memory of 200 byte size which creates allocated memory in the system for storing the data static as the name tells it has fixed in size type of memory.Also we cannot reuse the memory once it gets allocated.it has high speed performance. DynamicJsonBuffer This library supports DynamicJsonBuffer since it has parameters for dynamic memory allocation but it will be more useful if we use this buffer in the machine having memory more than 10KB of RAM. to use this syntax is just similar. DynamicJsonBuffer jsonBuffer; This will create one dynamic memory for the system so that it can allocate it more precisely.its size is variable it stores the data in heap.while storing it take time and its somehow pro...

How to create a NAS using Raspberry-pi?

What's a NAS? Network-attached storage allows you to share files from one, always-on device throughout your house. With a NAS on your network, you can use it to store your movies and play them from multiple Kodi boxes, store backups on it from your PC, or use it as a BitTorrent box that seeds your files 24/7. Sure, you could do all this with your main PC, but a NAS is lower-power, and it is designed to be run day and night, even if your desktop is out of commission. Once you start using one, it's hard to go back. There are plenty of ready-built NAS devices out there, from companies such as Synology, QNAP, and Asustor. Just buy one, pop in a hard drive, and you're off to the races. But they can get expensive quickly, and if you aren't sure whether a NAS is for you, it's hard to justify the investment—especially if you want something that can grow with your storage needs. The Raspberry Pi, on the other hand, is such a versatile little board that it can act as a cheap ...