Tag Info

New answers tagged

4

Okay so i did some research and it is interpretting the first number as the year, it would appear that the + and entirely superficial and completely ignored. Using your examples. $ date -d'1 February' Sun Feb 1 00:00:00 CET 2015 Works entirely as expected as no year is supplied. $ date -d '1 February + 1 week' Thu Feb 8 00:00:00 LMT 0001 Almost ...


2

It appears to be interpreting the 2nd digit as the year and then assuming 1 week(s), so always add a year, as this year then I think you will get what you desire. eg. christian@fujiu1404:~$ date -u -d'1 feb this year -2 weeks' Sun Jan 18 00:00:00 UTC 2015 christian@fujiu1404:~$ date -u -d'1 feb this year +2 weeks' Sun Feb 15 00:00:00 UTC 2015 ...


2

Just for completeness, you dont need all those (") nor the final $(echo ...). Here's the simplified version of your assignments that produce the same effect: STARTIME=$(date +"%T") ENDTIME="$STARTIME today + 10 seconds" CALL="date -d '$ENDTIME' +'%H:%M:%S'" Note how you dont need to quote when doing var=$(...) but you do usually with var="many words": ...


0

Put single quotes inside your double-quoted ENDTIME variable, like so: ENDTIME="'$STARTIME today + 10 seconds'" CALL="$(echo date -d "$ENDTIME" +'%H:%M:%S')" It should give date -d '19:35:28 today + 10 seconds' +%H:%M:%S


1

You can edit your call statement as: CALL="$(echo date -d \"$ENDTIME\" +\'%H:%M:%S\')" The \ can be used to escape the characters " and '. Now echo $CALL will output as: date -d "22:46:37 today + 10 seconds" +'%H:%M:%S'


1

The reason your test fails is because the condition test uses a value of $? that is non-zero. The reason it's non-zero is because date is producing a non-zero exit status. If you temporarily stop discarding date's stderr with the > /dev/null 2>&1 you'll get to see the error message it's producing. That will help you identify the issue. date: ...


7

Almost all programs use the TZ environment variable to determine the timezone, and fall back to the system setting if that variable is not set. TZ=Pacific/Yap date TZ=Pacific/Yap xclock Almost all operating systems (even Windows) use timezone information from the IANA database. Most timezones have a name of the form Continent/Town where Town is typically ...


5

The command date '+%d.%m.%Y' creates this output: 14.06.2015. To assign it to a variable d use: d=$(date '+%d.%m.%Y').


10

You can use zdump: NAME zdump - timezone dumper SYNOPSIS zdump [ --version ] [ --help ] [ -v ] [ -c [loyear,]hiyear ] [ zonename ... ] DESCRIPTION Zdump prints the current time in each zonename named on the command line. Example: $ zdump ~$ zdump Iceland Iceland Sun Jun 14 09:40:30 2015 GMT $ zdump Japan Japan Sun Jun 14 ...


18

Timezones are listed in /usr/share/zoneinfo. If you wanted the current time in Singapore, for example, you could pass that to date: TZ=Asia/Singapore date Sun Jun 14 17:17:49 SGT 2015 To simplify this procedure, if you need to frequently establish the local time in different timezones, you could add a couple of functions to your shell rc file (eg, ...


1

You should IMO not launch the systems date-time picker unless your customers insist on their look and feel. If you really need to do so you need the http-server (apache, ngnix or whaterver else you are using) to start a program that displays on X surface. For this you need to: trigger something in your backend software that will start the program Y that ...


0

I'm surprised you got anything given that stat -f "%m" ... is not valid. Are you sure you copied the current version of your command? It looks like you are using -c (specify format) not -f (filesystem) you you get the mountpoint for the list of files you provide to stat, which you then truncate to a single path and then have date stat the mountpoint and ...


0

for a sed answer, you could use this to filter out the decimals : sed 's/\.[0-9]\{1,\}//' How it works : \. will match a literal . [0-9]\{1,\} will match one or more digits The resulting pattern means "match a literal . followed by one or more digits" and replaces this with nothing.


0

If i usderstand your question correctly. Your desired output is out.txt sys00 finished around: 2015-06-11 01:42:29 sys01 finished around: 2015-06-11 01:21:17 sys02 finished around: 2015-06-11 03:51:56 sys03 finished around: 2015-06-11 04:32:12 sys04 finished around: 2015-06-11 01:40:47 sys05 finished around: ...


6

- 1 month will subtract one from the month number, and then if the resulting date is not valid (February 30, for example), adjust it so that it is valid. So December 31 - 1 month is December 1, not a day in November, and March 31 - 1 month is March 3 (unless executed in a leap year). Here's quote from the info page for Gnu date (which is the date version ...



Top 50 recent answers are included