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
1answer
24 views

RedHat + what is the variable ARC in the /etc/sysconfig/clock file

from redhat doc we can see the following: The /etc/sysconfig/clock file controls the interpretation of values read from the system hardware clock. ARC=, where is the following: false or no — This ...
0
votes
2answers
33 views

red hat Linux + UTC properties and hw clock

from redhat documentation The /etc/sysconfig/clock file controls the interpretation of values read from the system hardware clock. UTC= where is one of the following boolean values: true or yes — ...
1
vote
1answer
30 views

Get Timestamp 00:00:00 Yesterday in bash shell

I have a script want to get timestamp in begin yesterday (00:00:00 GMT+0) but cannot excute this script dateto=$(date --date="1 days ago" +"%Y-%m-%d") datetoj=$(date +%s --date "$dateto 07:00:00") &...
1
vote
2answers
323 views

Can I convert a date in the format YYYYMMDDHHMM using date?

I have a date of the format YYYYMMDDHHMM. For example, 201607131001 would be 10:01 AM July 13, 2016. Is there any way I can use the date utility to format the timestamp?
0
votes
1answer
36 views

HH:MM:SS (with AM/PM) 12 Hour Timestamp for Bash Prompt

I'm trying to add a timestamp to the beginning of my bash prompt in the format of a 12 hour HH:MM:SS AM/AM clock, and as of now, I've had no luck. Here's a couple things I've tried. I've tried date +%...
0
votes
0answers
45 views

TIMEZONE set for specific country but we get UTC Time - how it can be?

I have Linux red-hat 6.6 version This machine was set for Israel time zone as the following # more /etc/sysconfig/clock ZONE="Israel" ls -ltr /etc/localtime lrwxrwxrwx 1 root root 23 Jul ...
-1
votes
3answers
58 views

How to determine & convert current time to no of seconds elapsed during current day?

I want to ask your that how to determine & convert current time to no of seconds elapsed during current day? Actually, I want to show how long is midnight from now in seconds. As total seconds ...
1
vote
2answers
49 views

how to trim a date to format of 00/00/0000?

I am new and have a very naive question. I want to trim and substitute the already extracted date in a .csv file from 0/0/0000 to 00/00/0000 for instance 1/9/2016 --> 01/09/2016 I have this script ...
3
votes
4answers
59 views

Force date to read Day/Month/Year

How to I get the GNU date command to interpret dates in the format 'dd/mm/yyyy', for example: What I get: $ date -d '09/07/2016' Wed, Sep 7, 2016 12:00:00 AM What I want: $ date -d '09/07/2016'...
0
votes
1answer
33 views

view IPs from apache access.log for date period

I have seen someone use this command -- and it works where it pulls back all the IPS in a list/group: cat access.* | awk '{ print $1 }' | sort | uniq -c | sort -n However, I want to choose the past ...
2
votes
2answers
42 views

how does the gnu coreutils `date` work? [closed]

I did not see any similar questions on this site. The manpage, while helpful in describing how to use date, did not have much background info. Even the info page (as prescribed in the manpage: info '(...
0
votes
1answer
39 views

Why do these commands produce different outputs?

I am trying to get the linux timestamp from a row of text. I can use the cut command to grab the string > echo '"tester_row_____",0,"2016-07-04T01:42:28Z","2016-07-04T02:00:58Z"' | cut -c 22-41 ...
0
votes
1answer
59 views

Display Date Command

Need to export variable with date command and need the format like this export etool_start=`date +"%Y%m%d%k%M echo $etool_start 201607032314 This works fine when date digits are between 10-20. When ...
1
vote
2answers
39 views

Setting old system date

I have a Centos 7 server running in a cloud-server provider (ProfitBricks). I need to setup a demo system but is really hard to create daily fake data. My idea is to configure this server with an old ...
1
vote
1answer
40 views

Compare dates in a list

So I have a list of dates and I need to develop a script that keeps a rolling count of how many dates are older than 14 days (date --date="14 days ago" +%Y%m%d). Not sure how I can have the date check ...
0
votes
1answer
450 views

Check if date is n years old

I have a variable $date with format yyyy-mm-dd and I would like to check if it is exactly 1 year, 2 years (and so on) old. That's what I tried so far: dates=$(echo $date | cut -c6-10) todays=$(date +...
4
votes
4answers
51 views

Generate line number / “index” within a range from a date seed value

I'm trying to create a bash script to display a word of the day (random for each day). I have a dictionary file that on each line has a word and its definition. I'd like to use date to get a unique ...
2
votes
3answers
2k views

Date in milliseconds on OpenWRT on Arduino YUN

I am using OpenWRT on the Arduino YUN and I am trying to get the exact date in milliseconds (DD/MM/YYYY h:min:sec:ms) by getting the time by an timeserver. Unfortunately date +%N just returns %N, but ...
3
votes
3answers
6k views

How to get previous year and previous month in solaris 8

How to get previous year and previous month in solaris 8? I have tried below command but none of them is correct: date +'%m' -d 'last month' date +'%Y' -d 'last year'
0
votes
1answer
35 views

Change last edited date [duplicate]

How can I change the last edited date of a file? There doesn't seem to be anything like: chlastediteddate 12/7/12 file What command can do this? Is there a way to do this without changing what the ...
0
votes
2answers
1k views

Display all the dates in week numbers in UNIX [closed]

I know the command to get the week number of a date is date +%W Output: 03 Now, is there a way of giving a week number it will display all the dates in that week? Or should I write a script? Eg: ...
1
vote
1answer
36 views

Converting date/time to current JDN

I would like to convert a date/times to the Julian Date (number of days since Jan 1 4713 BCE, not the YY-ddd form where ddd is the day number of the current year). This doesn't seem to be built-in to ...
0
votes
1answer
27 views

Set date with milliseconds from epoch

How do I set the date using milliseconds and or seconds from epoch? date -s 127846398127?
0
votes
1answer
69 views

Outputting date from an array with bash

I'm trying to put together a script that will detect when someone joins my network via DHCP and then will email me the details. The problem I'm having is with parsing the epoch time in the loop. I've ...
0
votes
3answers
107 views

Can I obtain microsecond granularity when I calculate the number of nanoseconds from Windows Epoch to today?

Using Ubuntu Linux 16.04 and g++, I was wondering if could obtain microsecond or millisecond granularity when I calculate the number of nanoseconds between Unix Epoch or Windows Epoch and an arbitrary ...
2
votes
3answers
56 views

Get file modification time in yyyymmddhh24miss format

I want to get the modification time of a file in a specific format. How can I do that ? I know about stat -c %x find.txt but I need this format: yyyymmddhh24miss I'm using ksh on Linux 2.6.18-...
2
votes
2answers
91 views

Getting the date from a ssh client

I have a problem with an embedded computer where it does not have a separate Real Time Clock and as such every time I reboot it, it loses track of the current date. This is very annoying because lots ...
0
votes
1answer
65 views

inserting modified date into filename - 2 cases

I believe I'll ask two separate questions, but the context is the same, so I hope it's alright. I have an output of few processes as presented below (which I can't modify). 25978.csv 26044.csv 26865....
0
votes
2answers
35 views

FreeBSD date utility -r switch confuses me

I have a bash script which I need to convert from linux to FreeBSD, but I'm obviously too stupid to read the man page in a proper way. The script has a line along: date +%d -r "$file" which works ...
1
vote
1answer
19 views

Display the package date in the Aptitude UI

The Aptitude README (on Ubuntu 16.04, under /usr/share/doc/aptitude/README) gives the escape codes to customize how the packages are displayed in the UI (typing aptitude without any parameters at the ...
29
votes
10answers
4k views

Year 2038 problem [closed]

What is the likelihood of the Year 2038 issue being very problematic?
15
votes
5answers
67k views

Appending a current date from a variable to a filename

I'm trying to append the current date to the end of a file name like this: TheFile.log.2012-02-11 Here is what I have so far: set today = 'date +%Y' mkdir -p The_Logs & find . -name The_Logs -...
0
votes
0answers
85 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 ...
3
votes
2answers
56 views

Prevent updates to 'modified time' when copying files to a mounted Samba folder

I don’t want the “last modified” attribute to be changed to the current date when copying files to a mounted Samba folder. How can I do this? This behavior occurs with (K)Ubuntu 12.04 and Ubuntu 15....
3
votes
2answers
4k views

Get time for system default timezone

When logging in to remote machine X, by default, date will give the time in the local timezone: $ date Mon Nov 17 22:45:47 CET 2014 Note that TZ is not set: $ export | grep TZ $ So, I set TZ to ...
4
votes
2answers
104 views

Millisecond time in a shell script

How can someone print the entire time ie, for example 12:07:59:393(HH:MM:SS:milliseconds) in milliseconds. I found a lot of posts saying how to print Milliseconds along witht HHMMSS but I want to ...
5
votes
3answers
1k views

mutt: conditional date format in “index_format”

I have following value set for index_format in mutt: "%Z %{%Y %b %e %H:%M} %?X?(%X)& ? %-22.22F %.100s %> %5c " which displays date in the format as 2013 Dec 5 I was wondering whether ...
-1
votes
1answer
22 views

Why %H%M%S is not working in .screenrc?

According to this answer, I can rename logfile of screen with date to avoid logfile appending problem But %c used in that answer contains a colon, like 19:00. Since I have to sync files with windows, ...
0
votes
1answer
52 views

command /opt/bin/date --date '-15 minutes 2016-04-27T14:14:47' producing result many hours before stated time

I'm using the following command in an attempt to work out the time 15 minutes before the timestamp: /opt/bin/date --date "-15 minutes 2016-04-28T16:58:55" '+%Y-%m-%dT%H:%I:%S' The problem is the ...
4
votes
3answers
126 views

UTC vs. localtime has an offset of about 25 seconds

I have compared this in different systems, but only get this behavior in an embedded system running Arago linux. I use the date command from BusyBox v.1.13.2 I executed this two commands "...
3
votes
1answer
103 views

How do I set up busybox to allow a non-root user to set the date?

I have an embedded system built with busy box. I allow a user named "app" to download a program/script to a directory and it will be run on boot. The program should be allowed to set the date. It ...
20
votes
6answers
69k 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? [root@...
-1
votes
1answer
25 views

adding date to beginning of file name using script

I have multiple files that need to be renamed with a date added to the beginning of the file name that I am trying to script. I'm using the cp command because I need to keep the original file I need ...
1
vote
2answers
63 views

at now - different date

This is my current system date root@48392:/home/# date Mon Apr 25 19:08:13 CEST 2016 Now I set up an at job... root@48392:/home/# echo "ls" | at now warning: commands will be executed using /bin/...
1
vote
2answers
56 views

Time travelling and log files

When testing changes to a legacy codebase on a development system, my preferred method of testing is to set the system clock to a date in the past, eg date -s '-7 days', I then playback some ...
1
vote
4answers
206 views

Dangers of using rm command with variables

I am creating a crontab that compresses 15 minute clips from my security camera into one file (24 Hours Long) and then having the clips delete. avimerge -o /media/jmartin/Cams/video/Full_$(date +%F --...
0
votes
1answer
69 views

How do you put date and time in a file name?

I'm trying to execute a command and would like to put the date and time in the output file name. Here is a sample command I'd like to run. md5sum /etc/mtab > 2016_4_25_10_30_AM.log The date time ...
5
votes
3answers
2k 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 "$(...
14
votes
4answers
5k views

Why does TZ=UTC-8 produce dates that are UTC+8?

The current time in Los Angeles is 18:05. But when I run TZ=UTC-8 date --iso=ns, I get: 2013-12-07T10:05:37,788173835+0800 The date utility tells me that the time is 10:05, and even says that it's ...
-1
votes
2answers
72 views

How to convert a string into a date in a given format

Need a string in '9-2-1832' format in a '1832-09-02' format. Must be able to fill a 'date' type field in mysql.