Questions tagged [date]
the "date" tag is used to classify questions about date/calendar/time manipulation, visualisation, conversion... on Unix-like systems.
1,161
questions
0
votes
3
answers
55
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.
0
votes
1
answer
91
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/...
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 ...
16
votes
4
answers
3k
views
date - Can't Go Back More Than 115 Years or Can't Go 5879565 Years Into the Future
TZ=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 possible to ...
3
votes
1
answer
79
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 ...
0
votes
2
answers
311
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 !
3
votes
0
answers
55
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 ...
0
votes
1
answer
44
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.
2
votes
4
answers
582
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 ...
7
votes
2
answers
468
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 ...
3
votes
3
answers
296
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:
...
2
votes
2
answers
184
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....
1
vote
0
answers
83
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 ...
0
votes
1
answer
109
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 ...
0
votes
1
answer
19
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'...
0
votes
1
answer
401
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. ...
0
votes
1
answer
38
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?
0
votes
0
answers
19
views
date -d 'last month' yielding incorrect results? [duplicate]
I noticed an awkward (at least to me) behaviour of the date command:
jasio@zuza:~> date -d 'this month'
śro, 29 mar 2023, 15:51:42 CEST (1)
jasio@zuza:~> date -d 'last month' (2)
śro, 1 mar ...
-1
votes
2
answers
161
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 |...
-5
votes
2
answers
63
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)
1
vote
1
answer
377
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 ...
0
votes
3
answers
444
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 ...
0
votes
1
answer
42
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&...
0
votes
1
answer
101
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 ...
2
votes
2
answers
122
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 ...
0
votes
0
answers
357
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 ...
4
votes
5
answers
764
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,
...
0
votes
0
answers
26
views
Previous month in AIX [duplicate]
I would like to get previous month in my AIX env.
date +%B-\%Y -> gives me February-2023
I need to get January-2023
Any idea which command?
Thanks in advance
0
votes
0
answers
18
views
Why does bash date not pick up the variable changes in a loop? [duplicate]
Consider the following:
$ echo "${s}"
2022-11-03
$ e=$(date --date="$s + 1 day" "+%F %T"); echo "${e}"
2022-11-04 00:00:00
I'm trying to write a loop so that I ...
1
vote
3
answers
138
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 ...
0
votes
1
answer
52
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 ...
1
vote
1
answer
153
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' -...
1
vote
2
answers
186
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 ...
0
votes
1
answer
175
views
terminal timer with end time given through bash
so I had the idea of making a bash function that takes in a time in hh:mm:ss (24 hour format) and makes a timer till that time
kinda like a one time alarm while also showing how much time is left
I ...
2
votes
0
answers
76
views
Watch command -d=cumulative gives unexpected behavior with --color
This script gives the expected behavior, highlighting the parts of the date that change:
watch -d=cumulative date
However this script highlights the entirety of the text instead of just the things ...
0
votes
0
answers
23
views
Copying folders within archive and preserve metadata
Im using 7zip in ubuntu 22.04 and Im using this command
7z l -slt "/media/azeem/368A-5AA7/airdroid test folder made with winzip.zip"
airdroid test folder made with winzip.zip file is what I ...
2
votes
1
answer
753
views
How to change the time zone string of date command?
I'm curious about how to change the abbreviation of time zone shown by date command.
Let the time zone unchanged, but how to change CST below to UTC+8?
clay@LAPTOP-3PP2093I:~$ date
Thu Dec 1 23:05:28 ...
0
votes
1
answer
448
views
How to show seconds in time format of KDE lock screen?
I am using Russian locale and I use KDE. When locking screen with Meta + L, you see the current date and time on it. The time is in format "12:34". I want to change it to "12:34:56"...
1
vote
1
answer
151
views
Date output in 12hr format
I am using the date command in my script to get both date & time by adding some minutes.
date --date 'now + 60 minutes'
Mon Oct 31 09:45:46 IST 2022
Currently I am getting the output in 24Hr ...
1
vote
1
answer
20
views
Can `cal` show other Gregorian adoptions?
On my host I can show the adoption of the Gregorian calendar as it occurred for Great Britain and its colonies in 1752:
$ cal september 1752
September 1752
Su Mo Tu We Th Fr Sa
1 2 ...
1
vote
0
answers
658
views
Failed to start Network Time Synchronization
Can anyone let me know why I am facing Failed to start Network Time Synchronization at the kernel logs?
When I run timedatectl command I get the message
Failed to query server: Connection timed out
...
0
votes
1
answer
106
views
How can I obtain the time stamp from a file or directory in touch format?
According to many websites I found online the touch commands' -t argument accepts the time stamp in the following format:
[[CC]YY]MMDDhhmm[.ss]
Here,
CC: The first two digits of the year.
YY: The ...
0
votes
2
answers
515
views
Issue with timedatectl
Hi can any help me how timedatctl works my understanding are
if system clock sysnc with NTP serivce through internet system time will be updated to current date and time.
If system clock sync with ...
6
votes
1
answer
843
views
Is there a reserved word for datetime for the start of the day?
man date won't show me any reserved words but they have 'now' or 'today' etc.
I wonder if there is any clear way to print start(00:00:00) of the day.
Will date -u -d "$(date +'%F')" suffice ...
0
votes
1
answer
572
views
How to change the modification date (The Metadata) of multiple files?
I have a gallery folder with multiple images and videos, some of them has their modification date correct, and some of them has the month wrong.
I want to make a script that will change all the files ...
0
votes
1
answer
31
views
How to disable time sync in a VMware shared folder?
My Windows 10 desktop has VMware. To set past time in VMware, I disabled sync options as described here: https://kb.vmware.com/s/article/1189
I just tried to set the date to past time in VMware. And ...
2
votes
2
answers
1k
views
Script - Compare filename date with current date
I'm trying to compare a file with date in its name to the current datetime of the system:
Filenames are with the following format:
FileName.yyyymmdd.hhmm.file (e.g. File156tr.20220914.0958.txt)
I have ...
4
votes
4
answers
1k
views
Precision of the date command and arithmetic
I take a date at nanosecond precision:
$ start=$(date '+%s.%N')
...then print it:
$ echo ${start}
1662664850.030126174
So far so good. But look what I get when I printf with some arbitrarily huge ...
0
votes
3
answers
262
views
Read and convert date from file
I'm using a CentOS and I want to write a shell script. So
I have a file with a date:
>
> cat VM1_EOMAP_TIME.log
07 Sep 2022 16:30
>
And I want to get the minutes since current time and the ...
0
votes
0
answers
85
views
change date languge
I'm working on Reh Hat linux server,I want to change date language to "French".
when I run the command date I get Thu Aug 25 13:30:25 CEST 2022 as you can see, the language used is English ...