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

learn more… | top users | synonyms

1
vote
2answers
119 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
101 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 ...
4
votes
3answers
445 views

Struggling with date command

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
91 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
89 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
25 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
614 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
66 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
85 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
41 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
131 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
35 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
236 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
48 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
257 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
51 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
400 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
39 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" ...
1
vote
0answers
33 views

date/time setting does not work after unplugging power adapter or sudden power cut

For some reason, I want to configure the date/time in my Linux (CentOS 6.5) to be different from the REAL date/time, but the setting won't work if I turn my computer(desktop not laptop if this ...
10
votes
3answers
850 views

What's a smart way to count the number of days since X?

I started working at my current position since November 17th 2014. I would like to know how many days have run up to now. Any ideas on how to use Linux to come up with a simple and nice solution ?
14
votes
3answers
1k views

Date validation in shell

I want to validate the below date format in shell script 2015-Jul-13 I'm using date -d "2015-Jul-13" +"%Y-%b-%d" but its giving error as date: invalid date '2015-Jul-13'
1
vote
1answer
77 views

Why is the localtime reset to the default timezone?

I use the following commands to set the timezone on our Amazon Linux (Centos) server: ls -al /etc/localtime -rw-r--r-- 1 root root 118 25 dec 2012 /etc/localtime sudo mv /etc/localtime ...
2
votes
3answers
125 views

epoch time for GMT

On AIX date -u gives date and time in GMT format date gives date and time in local timezone date +%s gives local time in epoch time Is there a way to get GMT time in epoch format? In the AIX I'm ...
4
votes
4answers
425 views

How to compare two dates without using Stat?

I'm trying to compare the last date modified of a file to today's date. If the modification date is before today's date then my script will do one thing, if the date matches todays date i need it to ...
4
votes
2answers
74 views

date processes first parameter incorrectly if it is not 1

I am using date (GNU coreutils) 8.22 and having some trouble to calculate a date after a given one. Say I want to use 1st of February, for example: $ date -d'1 February' Sun Feb 1 00:00:00 CET 2015 ...
0
votes
3answers
661 views

In bash, how to call a variable and wrap quotes around its value as part of a command without causing the variable name to become a string literal?

So I want to add 10 seconds to a time. The command to do that came from here. To illustrate: STARTIME="$(date +"%T")" ENDTIME="$STARTIME today + 10 seconds" CALL="$(echo date -d $ENDTIME ...
0
votes
1answer
446 views

Unix date format validation script

I wrote this small unix shell script to validate the date format. My script should check whether the string is in YYYYMMDDHHMISS format . If it is not in this format , it should send an error message ...
0
votes
1answer
48 views

Print a date with leading zeros

My requirement is to print date like this, 04.10.2015 I have tried, d=`date '+%d%m%y'` But the problem what was happening, it was printing those dates which are two digits (10 to 31). But 1 to 9 ...
12
votes
3answers
1k views

How do I get the current time in a different time zone without changing system time? [duplicate]

I am trying to use 'date' to get the time in a different time zone, and failing. All the methods I've found on google involve changing the time zone on the system, but that is not what I want. Is ...
1
vote
1answer
57 views

install date time picker on ubuntu server [closed]

I've recently created a kiosk which uses openbox and xorg in order to be able to show the browser. Is there also a way that I can run some command in the server and it will open a graphical date and ...
2
votes
3answers
72 views

Truncating the precision of a date

I'm working with a bash script which polls build progress from several different systems. If a build is complete, it stats a log file to find out the last time it was edited, then feeds that time into ...
6
votes
1answer
1k views

How does the “1 month ago” option in date command work?

I'm not sure if this gets the past date within the current day or if it only takes 30 or 31 days to it. e.g. If the current date is March 28th, 1 month ago must be February 28th, but what happen ...
0
votes
1answer
104 views

set my system date & time via terminal

I don't why a + sign appears in the my program: <ns1:ST>2015-05-23T18:00:00+04:00</ns1:ST> <ns1:ET>2015-05-23T18:15:00+04:00</ns1:ET> this is when I run the program in my ...
6
votes
1answer
187 views

Change a locale definition (as opposed to a locale setting)

Preliminary remark: This question is not about setting a locale by changing LC_ALL, LC_TIME, LANG, etc., it's rather about changing a locale definition, e.g. in /usr/share/i18n/locales/de_DE, or ...
3
votes
0answers
155 views

Best practice to customize date/time format system-wide?

I'd like to customize exclusively the date and time format for my system, while sticking to the rest of the locale as is. I know that environment variable LC_TIME will make it possible to customize ...
3
votes
1answer
2k views

Copy a file and append a timestamp

I've got two issues with my script that copies files and adds a timestamp to the name. cp -ra /home/bpacheco/Test1 /home/bpacheco/Test2-$(date +"%m-%d-%y-%T") The above adds Test2 as the filename, ...
2
votes
3answers
135 views

Reformat date string

I am trying to figure out how to reformat a file full of wrongly formatted dates. The source looks like this: {"_id":"","timestamp":"Mon Apr 20 08:30:55 +0000 2015"} {"_id":"","timestamp":"Mon Apr 20 ...
1
vote
1answer
82 views

Using date -1day with wget

I want to use wget with a cron to pull a file everyday however I want it to pull the previous days file from the remote server and the file is controlled by date variables in the URL as such: ...
1
vote
1answer
131 views

Usage of '%' in the crontab [duplicate]

I am trying to add a cron job to perform an rsync from a remote server to a (Ubuntu12) local machine & create a log file. Below is the crontab-l 00 18 * * * rsync -a -v --delete -e ssh ...
4
votes
2answers
84 views

Force time to stay put

The time on my Linux machine will not stay put. I need to test an issue with our server that only occurs on Saturdays. CentOS 6.5 64-bit I have NTPD off. (service ntpd stop and chkconfig ntpd off) ...
2
votes
2answers
209 views

date: bad conversion error on HP-UX but not on Linux

On Linux: $ touch 1 12 No problem,create 1 and 12. On SysV or HP-UX 11.31: $ touch 1 12 date: bad conversion I have tried with LANG=C, same error. Why?
1
vote
1answer
42 views

How to print a concatenated date and time in seconds

How can I print the following date 20150405 12:35:12 in seconds cur_date=20150405 cur_time=12:35:12 cur_datetime=20150405 12:35:12 this is what I am doing: cur_datetime=$cur_date' ...
4
votes
2answers
312 views

how to sort by the day of the week?

I have two files. file1: Dave 734.838.9800 Bob 313.123.4567 Carol 248.344.5576 Mary 313.449.1390 Ted 248.496.2204 Alice 616.556.4458 file2: Bob Tuesday Carol Monday Ted Sunday ...
0
votes
2answers
154 views

Change only the year on the output of the “date”-command

date for example displays Fri Apr 17 20:16:01 IST 2015 Now I want to change only the year so date should display Fri Apr 17 20:16:01 IST 2016 in this example. How to add 1 year to the output of date ...
1
vote
1answer
144 views

shell script for date checking between two days

There is date in my file, like 30-apr-2015. How can I compare this with the current date and get notified if they are equal?
0
votes
0answers
34 views

date advancing quickly ubuntu 14

after an upgrade of my server from ubuntu 12.04 LTS to ubuntu 14.04 LTS my system date is advancing quickly (taking 1h every 10 minutes). I tryied to install an ntp server to correct date but no way ...
1
vote
1answer
88 views

Figuring out the dates for a given week

With date -d @[some_timestamp] +"%U" the end result is a number between 0-53, which represents the week in which the [some_timestamp] is located. So if I have an arbitrary timestamp ie 1426815663, the ...
0
votes
1answer
80 views

How to accumulate data for the previous x number of days

Q: For the argument of the question, say today is 26/03/15. How can I 'accumulate' data for the last 5 days. But these dates are just an example. Ideally I would like to be able to accumulate data ...