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

learn more… | top users | synonyms

0
votes
5answers
100 views

Bash:decrementing american date by 1 day mmddyyyy

To simplify the problem, lets say I have variable: dat="10152015" (representing 15th October 2015) the result for dat should be 10142015 Note that I am not using today's date. What I have problem ...
0
votes
1answer
72 views

Convert date strings like 20 July 2017 to epoch and compare in Linux

I am using ksh, and have a text file with several lines of following content. I am trying to compare the date part to current date and find the difference in days and then output the "Server" and ...
0
votes
1answer
65 views

How to find files that were most recently created on file system?

I am trying to track the completion of a silent installer by detecting the presence of the last file created by it, but in order to do that I need to find out which file that is. Is there any way to ...
0
votes
2answers
53 views

Set yesterday Date in script special for Monday

I am writing a script a check whether exist a backup file every morning Monday to Friday. These backup file is saved in the end of everyday from Monday to Friday only named as 02_10_15 There is ...
1
vote
1answer
31 views

Extract entries from a file ranging from one date to another

There is a file which has entries with the first and second field as date and time in the following manner : 2015/10/14 00:33:37. The file has 100,000+ lines and is constantly updated. Entries in the ...
1
vote
4answers
235 views

How to get the last five business days in a Unix shell script using a `for` loop?

The following script: BUSSINESS_DATE=`date -d "-2 day" +"%Y%m%d"` for (( c=0; c<5 ; c++ )) do WEEKDAY=`date --date="$BUSINESS_DATE -$c day" +%w` if [ $WEEKDAY == "0" ] then ...
0
votes
2answers
71 views

Date format for variable

I need to write a variable with "date" function and I need that the format is yyyymmdd (i.e. 20151031). Also I would remove a day (i.e. 20151031 becomes 20151030) I would use bash. Thanks!
0
votes
1answer
137 views

Execute a command every minute forever using 'date'

I'm looking for a way (bash script or other) to make a command run every minute using date - I've been looking around for similar solutions but they all suggest either cron or watch but what I want to ...
0
votes
2answers
49 views

Get the first column of date linux

When I run date on my linux I get Sat Oct 31 11:53:22 BRST 2015. I want to get only Sat. How do I do that? So far I think I should use the code below but it does not work: date | printf $1
3
votes
1answer
143 views

Why does “date” show different times in root and user?

Using dpkg-reconfigure tzdata I have set my timezone to CST, but for non root users the system persists in using UTC time. pi@raspberry ~ $ date Wed Oct 28 18:14:08 UTC 2015 ...
0
votes
1answer
294 views

I'm trying to compile alsa-driver-RTv5.18 but get date-time error for gcc 4.9.2

/home/user/Downloads/Rt-Linux-HDaudio-5.18/alsa-driver-RTv5.18/alsa/acore/info.c:1065:22: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time] "Compiled on " __DATE__ " for ...
0
votes
0answers
59 views

Reset time / date to current time-zone using timedatectl preferably, or date

As the title says, I'm looking to reset the current system time to the selected time-zone using the timedatectl preferably, or date command. This is on the CentOS 7 OS, hence the timedatectl ...
0
votes
1answer
65 views

Error in 'date -d' command

Hmmm... Right now (Sat Oct 24 00:36:56 CDT 2015) on my Arch Linux system there appears to be a problem with the date command: $ date -d "+8 days" "+%A %d %B %Y" Sunday 01 November 2015 $ date -d "+9 ...
5
votes
3answers
381 views

Unix epoch in milliseconds

I'm prepending the Unix epoch with "nanosecond" precision into output of my command as below: $ command | while read line; do d=`date +%s%N`; echo $d $line; done > file I looked around to find ...
5
votes
2answers
308 views

Datecalc equivalent for Linux

Am using a script in ksh to get a date 91 days prior to today using datecalc on a Solaris 10 server. What would be the equivalent to this in Linux ? month=`datecalc -a $(date +"%Y %m %d") - 1 |awk ...
3
votes
2answers
160 views

How can I check whether $date1 is before $date2 in shell?

date1=$1 date2=$2 How can I check whether $date1 is before $date2? Both dates are in DD/MM/YY format i.e. 01/01/15.
1
vote
2answers
198 views

Compare two times in HH:MM:SS format - ksh

Is it possible to compare two time (24-hour format)? What I need is to just check if the first time is earlier than the second time. Example: $ ./script.ksh 09:30:15 13:00:34 okay $ ./script.ksh ...
1
vote
1answer
421 views

invalid date error for %m%d%Y format

I want to convert a String in %m%d%Y format to date. But, getting invalid date error as shown below: bash-4.1$ date -d '10042015' +"%m%d%Y" date: invalid date `10042015' How to fix it?
0
votes
4answers
2k views

check if date argument is in yyyy-mm-dd format [closed]

Is there a way to check if a date argument is in the correct format (YYYY-MM-DD)? I got this from the web but it doesn't work for me: date "+%Y-%m-%d" -d "2015-10-11" > /dev/null 2>&1 ...
1
vote
3answers
293 views

Excluding specific date and time in cronjob

I am trying to schedule a cron job where the requirement is the job has to run every day, every month and every min and every hour EXCEPT 2nd and 4th sunday of every month from 1 to 3 AM. Is there a ...
1
vote
1answer
165 views

BASH AWK Script add days to fixed date

My task is to export data from a database with the UNLOAD TO statement in dbaccess and convert it into a file, that can be inserted into a similar database. Now the problem: The old database (let's ...
0
votes
2answers
95 views

Subtract two dates using Shell Scripting [duplicate]

How can I subtract two dates in epoch format using Shell Scripting. I want the output in Months, Days, Hours format. Also It should work even for more than 12 months ( as I came across few which were ...
2
votes
4answers
51 views

how to get a different time-clock on CLI apart from your time-zone?

Is there a way to invoke or know a different clock or time on the CLI. The thing is I'm on UTC+5:30 time but at times need to know time in different time-zones. If there is a CLI way in which this can ...
3
votes
2answers
108 views

Script to compare job date to today's date and only output today's failures

Full disclosure: We do not have full access to the autosys database, so our only option for keeping history is to create an Oracle and use the autorep command to output data. We have Linux servers ...
-2
votes
1answer
41 views

How can I write a bash script that tells me how many hours there are from 23:43 to 02:10?

How can I calculate with hours and minutes in bash? For example say I want to write a script that takes two timestamps and tells me how many hours there are in between them, how can I do that? $ ...
3
votes
2answers
316 views

How to convert date from “Oct 01 20:00” to “Oct 1 20:00” format (space padded)?

Here Oct 01 has to be printed as Oct 1 i.e without 0. I need two spaces between Oct and 1 i.e like Oct 1.
5
votes
1answer
99 views

When is next Monday?

On my home computer (Xubuntu 14.04), I have zev@home:~$ date +%F 2015-10-05 zev@home:~$ date +%F -d "next Monday" 2015-10-12 whereas at work (Red Hat 5.11), I have zev@work:~$ date +%F ...
2
votes
1answer
253 views

Why does `date` show UTC time, even with a different timezone set?

I'm running Raspbian on a Pi 2, and I've run into a bit of a pickle. While I'm not sure this behavior was different previously, running date outputs the same time as date -u, despite my timezone being ...
1
vote
2answers
84 views

Compare two dates with different format [closed]

I have two files, each file contain a different date's format as below: File1: 2014-NOV-0620:59:59 File2: 2014-12-31 How can I compare those two dates in awk?
3
votes
1answer
120 views

Automatically synchronization between system time and hardware clock time

I'm working with a Linux embedded board. It uses Linux kernel v2.6.37 with an external I2C RTC cbc34803. I've successfully intergrated the RTC hardware. It works correctly except the problem ...
1
vote
2answers
195 views

How do I get the date from two weeks ago using Solaris' date?

Linux uses: date -d "2 weeks ago" +%b which is equivalent in Solaris?, I searched online, but nothing.
2
votes
1answer
203 views

How to get the current date and time in YYYYMMDDHHMMSS format in ksh88?

I am new to Unix and in need of some urgent help. I looked around a lot first to find how to get date difference (in a 1 or 2 liner code). But none worked for me. My requirement is to get difference ...
5
votes
3answers
1k views

How to format date output with spaces as variable in script?

I want to make the date command with nice formatting like this: $ date +"%Y-%m-%d %H:%M:%S" 2015-09-17 16:51:58 But I want to save this in variable, so I could call from script like this: echo ...
-1
votes
2answers
120 views

Script with input date, output day

I want to write a bash script that reads a keyboard input (date dd:mm:yy), stores it in a variable then echoes back the Day it corresponds to, ie Input : 03/08/2015 Output : Wednesday I'm having ...
-1
votes
1answer
130 views

How to get last quarter in Bash Script

I have a script that gets the proper quarter but I need to get the (quarter - 1) quarter=$(($(($((10#$(date -d $year$month$day +%m))) - 1)) / 3 + 1)) Currently this returns 3, I need it to return ...
13
votes
9answers
16k views

How to chain the commands 'date -d @xxxxxx' and 'find ./'?

I have directories whose names are timestamps, given in milliseconds since 1970-01-01: 1439715011728 1439793321429 1439879712214 . . And I need an output like: 1442039711 Sat Sep 12 08:35:11 ...
2
votes
0answers
27 views

Files appear in a different timezone after transferring to another computer (even though both computers have same timezone) [closed]

I copied some files from an Archlinux computer to an Ubuntu one, but the time on the files after being moved showed as exactly 2 hours earlier than on the computer they were originally. (2 hours I'm ...
3
votes
1answer
1k views

convert timestamp to epoch with bash builtin printf

While researching a different approach to convert a timestamp like 2015-09-08 11:07:35 to 1441703255 I found a lot of pretty commonly found solutions use e.g. date +%s --date ...
0
votes
1answer
90 views

Difference between two dates on Linux

I'm getting a date in the format of v_date=$(date +"%Y%m%d" -d "1970-01-01 + $(stat -c '%Z' file ) secs") v_sysdate=$(date +%Y%m%d) echo "$v_date" 20150907 echo "$v_sysdate" 20150907 ...
1
vote
2answers
111 views

Finding difference in dates which is in format “%Y%m%d%H%M%S”

I have a two dates in date +"%Y%m%d%H%M%S" format. How to find the difference and how to check whether the difference is more than 4 hours? This is how i have tried echo $(( ( $(date ...
0
votes
1answer
47 views

Issues with storing an echo of a date conversion into a string variable inunix

Apologies but this question comes from a question previously raised: How can I convert a local date-time into UTC date-time? Toby has been absolutely great helping me with some conversion string-->BST ...
2
votes
1answer
252 views

How can I convert a local date-time into UTC date-time?

I am trying to get a bash script working and in order to do so I need to transform a local time in +%Y%m%d%H%M%S format (example: "20150903170731") into UTC time in the same format. I know date -u ...
0
votes
2answers
38 views

Output date is not proper when the script is run using cron

The below line should provide an output date which when run manually gives an proper output such as Fri Jul 17 01:42:07 2015. But when run using cron, it gives the epoch date i.e. Wed Dec 31 19:00:00 ...
1
vote
3answers
309 views

change of date format in awk command

I have a file mdn.txt with following sample record. mdn.txt: 123456,2711448,1,20150214092425,20150714092425,120,20150814163821,,123,,,123,20150214092425,,123,,,123,20150214092425,,123,Y Now I want ...
1
vote
1answer
69 views

Why isn't `date` respecting my locale?

I am having some issues processing dates, where they are being interpreted in US format (mm-dd) instead of EU/AU format (dd-mm). It looks like date isn't respecting my locale settings, or they are ...
0
votes
2answers
62 views

How can I convert 14/Jul/2015 into 14-08-2015 [duplicate]

How can I convert 14/Jul/2015 into 14-08-2015? It is saying invalid date format because of the Jul element, but if I put 07 then it works fine. I have tried this: echo "Please enter the date: " ...
4
votes
3answers
339 views

Get date of next Saturday from a given date

I want the date of the coming Saturday after a given date. For example, for $date1="30-AUG-2015", I want the result 05-SEP-2015. I have tried all the commands below with no success: samba@samba:~$ ...
2
votes
1answer
71 views

Finding burn-date of a DVD

An ISO file has been burned into a blank DVD (in a Linux OS). Is there any commands in Ubuntu to check when the DVD was burned? I mean the date that the ISO file was burned, I do not mean the date ...
3
votes
1answer
498 views

Add 30 days in date

Using bash or mysql , how can I add 30 days in user expiry table? Example I have DB name USERS and table expiry like this: USERNAME EXPIRATION JOHN 2015-09-26 I want the command to take ...
2
votes
1answer
46 views

The arithmetic operations in bash date… ¿are reversed?

Edit: using Amazon Linux: Linux ip-xx-xx-xx-xxx 3.14.44-32.39.amzn1.x86_64 #1 SMP Thu Jun 11 20:33:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Output of this command: date +"%Y-%m-%d %H:%M:%S" ...