Difference between revisions of "Convert date to different format using date command"
From Notes_Wiki
(Created page with "Home > Rocky Linux or CentOS > Rocky Linux 9.x > Desktop tools and applications > Convert date to different format using date command '''Older article on this is at Date''' =Convert date in human-readable format to seconds since epoch (1 Jan 1970)= May databases and log files may output timestamp in seconds since 1 Jan 1970 instead of using human-readable format. In such cases convert date to...") |
m |
||
Line 1: | Line 1: | ||
[[Main Page|Home]] > [[Rocky Linux or CentOS]] > [[Rocky Linux 9.x]] > [[Rocky 9.x Desktop tools and applications|Desktop tools and applications]] > [[Convert date to different format using date command]] | [[Main Page|Home]] > [[Rocky Linux or CentOS]] > [[Rocky Linux 9.x]] > [[Rocky 9.x Desktop tools and applications|Desktop tools and applications]] > [[Convert date to different format using date command]] | ||
=Convert date in human-readable format to seconds since epoch (1 Jan 1970)= | =Convert date in human-readable format to seconds since epoch (1 Jan 1970)= | ||
Line 34: | Line 31: | ||
To change time / date from one timezone to other see [[Converting timezone using date command]] | To change time / date from one timezone to other see [[Converting timezone using date command]] | ||
'''Older article on this is at [[Date]]''' | |||
[[Main Page|Home]] > [[Rocky Linux or CentOS]] > [[Rocky Linux 9.x]] > [[Rocky 9.x Desktop tools and applications|Desktop tools and applications]] > [[Convert date to different format using date command]] | [[Main Page|Home]] > [[Rocky Linux or CentOS]] > [[Rocky Linux 9.x]] > [[Rocky 9.x Desktop tools and applications|Desktop tools and applications]] > [[Convert date to different format using date command]] |
Latest revision as of 07:56, 15 October 2022
Home > Rocky Linux or CentOS > Rocky Linux 9.x > Desktop tools and applications > Convert date to different format using date command
Convert date in human-readable format to seconds since epoch (1 Jan 1970)
May databases and log files may output timestamp in seconds since 1 Jan 1970 instead of using human-readable format. In such cases convert date to seconds using:
date -d <human-readable-date> +%s
For example:
date -d '1970-01-01 00:00 UTC' +%s date -d '2022-10-15 13:20 IST' +%s
Convert epoch time (seconds since 1 Jan 1970) to human-readable time
To convert epoch time to human readable time use:
date -d @<seconds>
For example:
date -d @1665820200
Convert timezone via date command
To change time / date from one timezone to other see Converting timezone using date command
Older article on this is at Date
Home > Rocky Linux or CentOS > Rocky Linux 9.x > Desktop tools and applications > Convert date to different format using date command