Skip to main content

Questions tagged [date]

the "date" tag is used to classify questions about date/calendar/time manipulation, visualisation, conversion... on Unix-like systems.

Filter by
Sorted by
Tagged with
0 votes
1 answer
37 views

Format date output with spaces into awk

I want to make the date command with nice formatting like this: awk -F, '{system("date -d " $1 " +%d/%m/%Y %H:%M")}' file.log However it does not work Try 'date --help' for more ...
Guif If's user avatar
  • 103
0 votes
1 answer
33 views

Script to find multiple files and update their timestamps by a second

I'm trying to create an interactive script that lets me choose a start date and time, then recurse into the present directory/subdirectories, find all flac audio files, sorted by directory/...
arcturus's user avatar
-2 votes
1 answer
75 views

How do I get lastlog timestamps in a generic format?

I have multiple Ubuntu machines in different locations. I want to collect the last login information from these machines. However, when I use the lastlog command, it returns dates in different formats....
Cong Thanh Huynh's user avatar
0 votes
1 answer
55 views

Where does `date` get the system timezone from?

I always thought Linux systems used /etc/timezone for the timezone, but: $ cat /etc/timezone Etc/UTC $ date Tue May 28 12:34:01 PM PDT 2024 Here, the /etc/timezone is UTC but date is reporting in ...
Jason C's user avatar
  • 1,485
0 votes
1 answer
60 views

What's the origin of the date format specifier "%b" for abbreviated months?

I'm working with the date command in Linux and I'm curious about the format specifier "%b". It outputs the abbreviated month name, which is great. However, I couldn't find a clear ...
Ilgar's user avatar
  • 3
0 votes
1 answer
31 views

Date is incorrect in wifi : system clock synchronization is not active

I have compiled a read-only rootfs image with yocto for my raspberrypi4. I have noticed that my date is incorrect uniquely in wifi. Indeed when I type the command timedatectl status I have the ...
void_brain's user avatar
21 votes
1 answer
3k views

How could March 30th 2024 be followed by the 1st?

I am in the EU zone +1 or when DST is on, +2. Now is Sunday 31.3.2024. This Sunday morning, we changed into DST, at 2→3 (CET → CEST). I have Linux servers in separate networks reporting monthly energy ...
Pila's user avatar
  • 465
0 votes
1 answer
80 views

How to generate a date in ISO 8601 format (UTC time) with an offset X days into the future? [duplicate]

When calling an API, I need to provide a start time and an end time in ISO 8601 format (UTC time). I want to call the API in a CRON job, so I can't manually create the date-time(s). How can I use the ...
Shuzheng's user avatar
  • 4,601
2 votes
6 answers
568 views

Convert EPOCH string in filename to readable format

My knowledge of Unix is not very good. I'm trying to write a shell script to rename a set of files in a directory, like 1709532255.mp4 to 20240304_070415.mp4, where 1709532255 is always an epoch time. ...
tom's user avatar
  • 23
0 votes
1 answer
31 views

Updating date for all files in scratch directory periodically

I am using a shared linux server that deletes files after 2 weeks. I would like to write a script that updates the date for all of my directories and files (basically, everything in my scratch ...
AWillz's user avatar
  • 1
0 votes
2 answers
111 views

Removing Minutes from Date as a Variable

I am writing a script in KSH and need your help to find the logic to remove minutes and seconds from the date. If users pass 2024-12-22-16-43-40 to a variable, it should be converted to 2024-12-22-16-...
jayvardhan's user avatar
0 votes
4 answers
127 views

how to subtract a date in format: 'xyz/[int][int]/[int][int][int][int]' from the current date?

Scenario I have containers which have last deploy dates in the format: month/date/year or feb/11/2024. I cant change the way they output the last deploy date. I'd like to subtract the last deploy date,...
Nickotine's user avatar
  • 489
0 votes
0 answers
28 views

highlight several dates in a year with gcal

cal or gcal are linux terminal programs which display a calendar gcal 2023 displays the entire year 2023 This question explains how to make it highlight todays date in the current year - Highlight the ...
cardamom's user avatar
  • 602
0 votes
1 answer
144 views

How to make crontab interact with session of currently logged-in user?

THE PROBLEM Crontab does work - but just aside, not in interaction with users. How to make crontab talk to currently logged-in user by automatically perceivable prompt output? For example, a wake-up ...
futurewave's user avatar
0 votes
2 answers
71 views

How can I generate a cumulative plot where I can view the number of files by the last modified date?

I have a large (millions) number of files in a folder, its subfolders and its subsubfolders that were modified over the past 15 years. I'd like to generate a cumulative plot where I can view the ...
Franck Dernoncourt's user avatar
1 vote
1 answer
186 views

Add hours to the date and time

I have a requirement to add offset hours to the datetime value. Get the previous date (e.g. 2023-10-19 00:00:00.000000) previous_date=`TZ=TZ+24 date '+%Y-%m-%d 00:00:00.000000'` Calculate the ...
Pixel's user avatar
  • 11
0 votes
1 answer
101 views

Fix the bogus modification time of some mkv files based on that of srt files with the same root name

I found around 50 mkv files with modification time in the future (year 2098 and 2097). I see that .srt files with the same name carry the right date and are located in the same subfolder as each mkv ...
Loop1's user avatar
  • 21
1 vote
1 answer
69 views

Change the last modification time of subfolders to that of the oldest file inside

Hello I would like to know how to scan and change the last modified date of all subfolders based on the oldest file in each subfolder. Example of Ubuntu folder structure: home/incoming/media/Something....
Loop1's user avatar
  • 21
2 votes
2 answers
117 views

What's the KISS-way of turning format '1000 days' into format 2 years, 9 months, 0 days' within bash & shell scripting?

What's the "Keep It Simple" way of turning a format such as '1000 days' into format '2 years, 9 months, 0 days' within shell scripting? I've thought of applying modulor or floor rounding. I'...
futurewave's user avatar
-3 votes
1 answer
90 views

What is the difference between the ip address with which I access a remote server vs the ip address which is shown in "ip a" command output?

It's bothering me. I'm an amateur at Linux networking so pardon me on that. I've heard terms like NATTED IP from others. But I am not sure what do they mean. A serious issue has arouse. And I need to ...
achhainsan's user avatar
0 votes
3 answers
474 views

In Linux how to find if a file was read and at what time

Is there a tool or command where we can see if a file was read and at what time? I would only find for last modified.
kumar's user avatar
  • 201
0 votes
1 answer
109 views

Need Help with Date expression - AWK in a csv file

Situation: csv file has date column with different date formats, I want to convert them into a unambiguous date format (like +"%m-%d-%Y"). Example File data : File name = Date_Test_new.csv 3/...
ArielUnix2023's user avatar
6 votes
2 answers
1k views

How can I set a time zone on a Linux machine that has only very minimal cmds available?

I have a Linux machine that only has very minimal cmds available on it, for example the /bin looks like this: /bin# ls ash chattr clockdiff dd dumpkmap ...
Henry's user avatar
  • 205
16 votes
4 answers
3k views

date - Can't Go Back More Than 115 Years or Can't Go 5879565 Years Into the Future

TimeZone = CEST date (GNU coreutils) 8.32 date -d "115 years ago" Di 11. Aug 13:37:54 CET 1908 date -d "116 years ago" date: invalid date ‘116 years ago’ Questions Is it ...
Bog's user avatar
  • 1,034
3 votes
1 answer
154 views

Is there a tool to test if a date-time is in a given range?

I need to develop a script to test if "now" (e.g. the output of date) is in a given range. For now, this range is expected to be a list of days of month (e.g. 10,11,12,13,21,22,23). And I ...
Juh_'s user avatar
  • 133
1 vote
1 answer
3k views

changing datetime format Ubuntu 22 [duplicate]

Looking for a solution for changing my machine datetime format to be DD/MM/YEAR hh:mm:ss. Currently ,Linux default is MM/DD/YEAR hh:mm:ss This is a GCP machine , running ubuntu 22.04.2 LTS . Thanks !
Dan Nir's user avatar
  • 11
3 votes
0 answers
182 views

How can I format the date and time in accordance with ISO 8601 / RFC 3339 using systemd?

How can I configure the environment of a systemd based Linux system to display the date system-wide in the format yyyy-mm-dd? This date format adheres to the specifications defined ISO 8601 and RFC ...
Jonas Stein's user avatar
  • 4,138
0 votes
1 answer
65 views

Write a script to obtain the date of the last month [closed]

I would like to obtain the date of the previous month as output and store it in a variable using a bash script. For example, if today's date is 07/04/2023, I would like the output to be 06/04/2023.
Ganesh Hite's user avatar
2 votes
4 answers
791 views

Changing non-standard date timestamp format in CSV using awk/sed

I have a csv with a few hundred thousand lines and I'm trying to change the date format in the second field. I should also add the second field is sometimes not populated at all. The deplorable input ...
user avatar
7 votes
2 answers
1k views

How to automatically set the modification (or creation) time of a Quicktime video file based on its meta data?

In a shell, how to automatically set the modification (or creation) date and time of a Quicktime video file based on the metadata in the file with a single command (or a single command line)? For JPG ...
user avatar
3 votes
3 answers
362 views

MAC OSX / Bash Problem - Sorting strings as a date

I have file output in a CSV file I want to sort by date time but the date time appears as below, with the time and year appearing in a different order. Using this command to produce the file listing: ...
Steve's user avatar
  • 31
2 votes
2 answers
341 views

Update any date to the current date in a text file

I have a text file which contains several occurrences of dates. All the dates are written in the format Mon-DD-YYYY. I have to update all these dates in the current date keeping the format Mon-DD-YYYY....
user9952796's user avatar
1 vote
0 answers
218 views

Linux UTM VM Hardware Clock is Incorrect

My machine natively runs MacOS Ventura 13.3.1. I am using UTM to run 5.14.8-arch1-1. I am on PST. The output of sudo hwclock --verbose is as follows: hwclock from util-linux 2.37.2 ... Hardware clock ...
user129393192's user avatar
0 votes
1 answer
356 views

Rsync with date filter over ssh

I use the following command successfully rsync -e 'ssh' -avr [email protected]:/home/mikrotik /bck/mikrotik/ How can I add date filter to this command? I would like to sync only files that are newer ...
mikia's user avatar
  • 103
0 votes
1 answer
26 views

Getting year of Postixct format

"Thu Apr 21 11:15:00.375 2022" how to get the year of this expression? Followings are tested. 1- as.POSIXct(strptime("Thu Apr 21 11:15:00.375 2022", format='%c'),origin='1970-01-01'...
Fkiran's user avatar
  • 3
1 vote
1 answer
2k views

Chrony - Synchronize the date and time of all host computers in a network without internet connection

I have two machines, host A with IP 192.168.0.1 host B with IP 192.168.0.2 They connected to the same network and I would like to set the date and time of machine B to match those of machine A. ...
UserK's user avatar
  • 2,464
0 votes
1 answer
51 views

Set explicit time with date

When I tried to set time with $(date +%s -d "2022-04-10 12:12:12") I get the time 2022-04-10 19:12:12 How can I set the time explicit?
Timestamp's user avatar
-1 votes
2 answers
391 views

Output date into specific column using bash

I want to output the date into a csv column using a bash script ignoring the header. I have this but it only gives the day of the week abbreviated and not does not place it in a specific column: date |...
robetus's user avatar
  • 113
-5 votes
2 answers
70 views

Unix: how to get number of days from a given date like 10Dec2022 [closed]

Team, Can someone help find code for below.. Unix: how to get a count of number of days from a given date like 10Dec2022 to today. Looking for Answer: 102 as of (22Mar2023)
RaviKumar's user avatar
1 vote
1 answer
1k views

Where is timedatectl information stored?

I am working on an embedded system without RTC battery. The time is synchronized via NTP when internet connection is available (which does not always happen). When the device is shut down, the time is ...
firion's user avatar
  • 149
0 votes
3 answers
1k views

Compare multiple date & time in shell script

I have below output with jq command , where I want to compare all the date & time and tell which is the latest one Mon Feb 20 09:22:25 2023 Mon Feb 20 17:42:13 2023 Thu Mar 2 05:55:07 2023 Tue ...
Samurai's user avatar
  • 55
0 votes
1 answer
61 views

find the time difference between two strings of fixed format as "DDD MMM dd hh:mm:ss HKT YYYY" [duplicate]

I grepped from the start time and end time strings from the program log. How can I find the time difference in hour? t1="Tue Feb 21 12:15:00 HKT 2023" t2="Tue Feb 21 12:45:01 HKT 2023&...
SBMVNO's user avatar
  • 103
0 votes
1 answer
268 views

How to fix Gnome Clock on Bar (date command seems to not use correct timezone)

Fedora 37 with Gnome Shell 43. On Status Bar on the top I see wrong time. But When I opening Gnome Clock app (this one https://wiki.gnome.org/Apps/Clocks) then I see correct time Also when I typing ...
Daniel's user avatar
  • 141
2 votes
2 answers
549 views

How to combine settings from multiple locales in Linux?

When I installed Linux I set my locale to en_US.UTF-8. However I want to override some but not all of the settings in that locale. Specifically, I would like the Measurement to be Metric instead of ...
bch6595's user avatar
  • 21
0 votes
0 answers
810 views

Format date to another date format in bash

I am retrieving the following dates from a database: 2022-04-12-08.22.28.940722 2018-10-30-10.28.10.112309 2022-04-07-14.13.19.426219 In my bash script I am writing them to a file (where the date is ...
Niek Jonkman's user avatar
4 votes
5 answers
1k views

How can I transform dates expressed with month names to numerical month designations?

I use MacOS and I have variable date in format 3.Jan.2023, 12.Nov.2017, 9.Apr.2022, ... I need to change in 03.01.2023, 12.11.2017, 09.04.2022, ...
Kire's user avatar
  • 53
1 vote
3 answers
169 views

Moving the year at the end of a directory name to the front, possibly convert into YYYY-MM-DD format

I exported all my pictures from Mac to my PC (Windows 11, but also running Ubuntu through PowerShell). The export created every directory (1000s of folders) in formats like the following and stripped ...
David's user avatar
  • 11
0 votes
1 answer
81 views

Modification date fields are not up to date in Nemo

I have a big folder containing several folders. When I open the big folder in Nemo, I noticed that the modification date of several of the subfolders was not up to date, even if files they contain ...
Karlo's user avatar
  • 125
1 vote
1 answer
293 views

Cannot set date in specific format

There is no problem to get the date with the command below: $ date '+%d%m%y %H%M%S.%N' 250123 170411.504761505 However setting it using the same format isn't possible: sudo date '+%d%m%y %H%M%S.%N' -...
ka3ak's user avatar
  • 1,265
1 vote
2 answers
390 views

A script to show the age of a linux installation in days

I want to create a command that is called Age which calls this script: From=$(stat / | grep "Birth" | sed 's/Birth: //g' | cut -b 2-11) echo $From Now=$(date) echo $Now However, I'm stuck ...
Saeed Neamati's user avatar

1
2 3 4 5
24