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
0answers
13 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 ...
1
vote
1answer
22 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
1answer
581 views

Bash script, ask for user input, to change a directory, sub directorys, and file's mtime atime linux recursively

Using GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) I am a bash scripting novice, not sure where to begin except at shebang #!. The following command. touch -a -m -t 201501010000.00 ...
0
votes
1answer
26 views

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

The below line should provide an output date which when ran manually gives an proper output like Fri Jul 17 01:42:07 2015. But when ran using cron gives the epoch date i.e. Wed Dec 31 19:00:00 1969 ...
1
vote
3answers
97 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
31 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
51 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 tried this: echo "Please enter the date: " read X ...
4
votes
3answers
150 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
25 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 ...
5
votes
3answers
15k views

List of Recently Modified Files

How can I Get a list of all files modified , say 3 months ago. I checked this question but I was not able to apply it to my scenario. I am trying this now , it seems to be working , but I know there ...
22
votes
3answers
89k views

Timezone setting in Linux [closed]

I'm setting the timezone to GMT+6 on my Linux machine by copying the zoneinfo file to /etc/localtime, but the date command is still showing the time as UTCtime-6. Can any one explain to me this ...
10
votes
4answers
22k views

Getting all files that have been modified on a specific date

Is it possible to find all php files within a certain directory that have been modified on a certain date I'm using find /var/www/html/dir/ -mtime -28 | grep '\.php' to get files modified within ...
41
votes
7answers
48k views

How do I convert an epoch timestamp to a human readable format on the cli?

How do I convert an epoch timestamp to a human readable format on the cli? I think there's a way to do it with date but the syntax eludes me (other ways welcome).
11
votes
3answers
504 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
35 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' ...
7
votes
4answers
1k views

Date computations without GNU tools

I have to perform some date calculations and conversion in a shell script. For example computing the difference in day between a date formatted as Nov 28 20:27:19 2012 GMT and today. There are ...
3
votes
1answer
320 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 ...
12
votes
2answers
16k views

show the year while listing files in the current directory

I am working on a red hat server I want to list the files in a way where the year when each was file created would appear in the Date how is that possible ?
2
votes
1answer
33 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
17 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
758 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 ?
4
votes
2answers
41 views

change time (date) in or from exif-data

On Change created date from exif data there are great scripts. But what if “Date and Time (original)” are bad in exif-data (because of wrong set time in camera). Is there a solution to change time for ...
3
votes
9answers
4k views

How to generate a year-quarter date from the command line?

I'm interested in outputting a representation of the current year-quarter, as well as the year-quarter for the previous month. If today is 2012 January 1st, I'd like to get 2012q1 and 2011q4 as ...
5
votes
5answers
7k views

Next day of the user entered date - date +1 day

I am new to scripting. I need a script in the AIX environment to get the next days date based on the date entered by the user. After hard time browsing for this, I got a piece of code which does the ...
1
vote
1answer
38 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 ...
1
vote
3answers
70 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 ...
3
votes
4answers
205 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
60 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
120 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
190 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 ...
10
votes
3answers
626 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 ...
0
votes
1answer
44 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 ...
1
vote
1answer
33 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
40 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 ...
10
votes
6answers
10k views

date, get current 15 minute interval

Is there any way I can get the current 15 minute interval using the date command or similar ? e.g. something like date %Y.%m.%d %H:%M will give me 2011.02.22 10:19 , I need something that yields ...
6
votes
1answer
237 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 ...
3
votes
6answers
26k views

Extract date from a variable in a different format

Let me explain you the problem $ date +%c -d "$d" Tue 31 Dec 2013 01:13:06 PM CET $ date +'Today is %F' -d "$d" Today is 2013-12-31 This solution corresponds to current date. But I have one ...
6
votes
5answers
47k views

Display time stamp in dd/mm/yyyy_hh:mm:ss:ms in Unix or Linux

I need help to display date and time in desired format in Unix/ Linux. My desired format is: dd/mm/yyyy hh:mm:ss:ms in Unix or Linux. I got close using the following command: echo $(date +%x_%r) ...
0
votes
1answer
65 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
110 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
83 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 ...
9
votes
5answers
28k views

How to append date to backup file

I need to make a backup of a file, and I would like to have a timestamp as part of the name to make it easier to differentiate. How would you inject the current date into a copy command? ...
3
votes
1answer
442 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, ...
1
vote
1answer
42 views

Unzip all non-existing or older files from archive

The behaviour I'd like with unzip is to extract all files, overwriting any that are older than those in the archive, not touching any that are the same age or newer, and to never prompt. The options ...
2
votes
3answers
80 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 ...
0
votes
1answer
73 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 ...
1
vote
1answer
47 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: ...
4
votes
2answers
71 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
137 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?
4
votes
2answers
151 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 ...