AIX DateTime Computation

Good day people,

Kindly advice on below please.

1) Formatting/ Arithmetic operation of given date

I understand from the AIX man date and some research that flag -d is not applicable for AIX shell scripting and some of the UNIX command date command is not available in AIX.
Please advice if there is any possible way for me to perform the identical operation in the following command on AIX.

echo $(($(($(date -d "2010-06-01" "+%s") - $(date -d "2010-05-15" "+%s"))) / 86400)) >> $2
date -d 'last week' >> $2
date -d "2010-01-01 +10 days" +"# %Y-%m-%d" >> $2
date -d "2011/07/13" +%j >> $2

2) Retrieve the first day and last day of month by a Julian date given.
I understand that Julian date of Now could be retrieved as following command.
date +"%r %a %d %h %y (Julian Date: %j)" >> $2
However, if there any function that I could retrieve the first day and last day of month by a Julian date given ?
Otherwise I will try to write a function to fulfill this requirement instead which might involve some regex and conditional case.

I noticed most of the suggestion solution across from research on this is writing a Perl script.. please advice if there is any other work around or AIX command that I can try on...

Appreciate for any advice.
Thank you.

Hello cielle,

Have you searched the board for date & time functionality? There are several threads that should lead you to what you want to do.

On the flip side, being AIX you can mess about with the TZ variable quite successfully. Up to AIX 6.1 (I haven't got a 7 implementation to test on) one can play with the offset used in TZ to move the relative clock around:-

ORIG_TZ="$TZ"
TZ="GMT168BST"             # Move clock back 168 hours, or 7x24, i.e. one week.  Adjust to your time-zone needs, of course.
date
TZ="$ORIG_TZ"

You may also get some joy with the following snippits of code:-

#Converts time in seconds to human readable time
perl -e 'print scalar localtime $ARGV[0],"\n" ' 12345678

#Converts almost human format time to seconds
perl -e 'use Time::Local; print timelocal(18,21,22,23,4,1970), "\n";'

Note that the format for the second conversion is:-
seconds, minutes, hours, day-of-month, month less one, yearIt works for me on AIX 6.1.8.3

I would love to offer something on Julian date. For more useful in an IT world, but sadly I do not know of a neat answer. It's on the board if you search though.

Regards,
Robin

1 Like