Popular Posts

Showing posts with label Time Zone. Show all posts
Showing posts with label Time Zone. Show all posts

Jun 20, 2018

Epoch Seconds to date & date to epoch seconds in Linux/UNIX

Epoch Seconds to date & date to epoch seconds in Linux/UNIX

APPLIES TO : All UNIX, Linux , HP-UX


1.        Convert Epoch seconds To date and Time format - Linux
                  date -d @1268727836

2.        Convert Epoch seconds To date and Time format - perl commands
                  perl -le 'print scalar localtime $ARGV[0]' 1528295738
                      Wed Jun  6 15:35:38 2018
                  perl -e 'print scalar(localtime(1528295738)), "\n"'
                      Wed Jun  6 15:35:38 2018
                  perl -leprint\ scalar\ localtime\ 1528295738
                      Wed Jun  6 15:35:38 2018

3.        Convert Epoch seconds To date and Time - Linux awk command
                  echo 1268727836 | awk '{print strftime("%c",$1)}'
                      Wed Jun  6 15:35:38 2018

4.        Print Current date and time in epoch seconds - Linux
                  date +%s
                      1528295738

5.        Current date and time in epoch seconds - Solaris
                  nawk "BEGIN{print srand}"
                      1528295738

6.        Current epoch seconds in Solaris and HPUX
                  perl -e 'print time()' ; printf "\n"
                      1528295738

7.        Find current epoch seconds using perl script
                  Judi-Dev-01 #  vi current_epoch.pl
                      #!/bin/perl
                      print "Current (epoch) time: " . time() . "\n";
                  Judi-Dev-01 # 
                  Judi-Dev-01 # ./current_epoch.pl
                      Current (epoch) time: 1529498830
                  Judi-Dev-01 #

8.        Convert date and time to epoch seconds
                  perl -e "use Time::Local; print timelocal($C_SEC, $C_MIN, $C_HOURS, $C_DAY, $C_MONTH1-1, $C_YEAR)"
                  perl -e "use Time::Local; print timelocal(01, 01, 00, 16, 6-1, 2018)" ; printf "\n"
                      Sat Jun 16 00:01:01 2018

9.        Display only time
                  date +"%T"
                      16:31:42

10.        Display date and time in local format (locale)

                  date +"%c"
                      Wed Jun 20 16:32:01 2018

11.        To get previous date in solaris (24 Hours per day) Calculate accordingly (Today is 16-Jun-2018)
                  TZ=GMT+24 date +%d-%m-%Y
                      15-06-2018
                  TZ=GMT+48 date +%d-%m-%Y
                      14-06-2018

11.        To get previous day in Solaris (86400 seconds for one day) Calculate accordingly
                  perl -MPOSIX=strftime -le 'print strftime("%d", localtime(time-86400))'
                      15-Jun-2018

11.        To get previous two days date in Solaris (86400 seconds for one day) Calculate accordingly
                  perl -MPOSIX=strftime -le 'print strftime("%d-%b-%Y", localtime(time-172800))'
                      18-Jun-2018



~Judi~







Nov 10, 2016

List / Get / Set / Change Time Zone and locales in Solaris 11

List / Get / Set / Change Time Zone and locales in Solaris 11


1. List the available time zones in server
judi-test-server1# nlsadm list-timezone
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa

US/Pacific
US/Pacific-New
US/Samoa
UTC
W-SU
WET
Zulu
judi-test-server1#

2.  Get current configuration - what time zone is set in server
judi-test-server1# nlsadm get-timezone
timezone=GB
judi-test-server1#


3. Set or change to a new time zone in server
nlsadm set-timezone US/Central

4. List available locales
judi-test-server1#  nlsadm list-locale
LOCALE              LANG  TERRITORY  CODESET  MODIFIER  FLAGS
af_ZA.UTF-8         af    ZA         UTF-8    -         -
ar_AE.UTF-8         ar    AE         UTF-8    -         -
ar_BH.UTF-8         ar    BH         UTF-8    -         -
ar_DZ.UTF-8         ar    DZ         UTF-8    -         -
ar_EG.UTF-8         ar    EG         UTF-8    -         -

en_GB.UTF-8         en    GB         UTF-8    -         -
es_US.UTF-8         es    US         UTF-8    -         -
judi-test-server1#

5. Set locale to en_GB.UTF-8
nlsadm set-system-locale en_GB.UTF-8

6. Get current configuration - which locale is set in server
judi-test-server1#  nlsadm get-system-locale
LANG=en_GB.ISO8859-15@euro
LC_CTYPE=
LC_NUMERIC=
LC_TIME=
LC_COLLATE=
LC_MONETARY=
LC_MESSAGES=
LC_ALL=

judi-test-server1#

~
Setting the Time Zone and Locale in solaris 11
How to change Time Zone in solaris 11
How to change Locale in solaris 11
List / get / view Time Zone in solaris 11
List / get / view Locale in solaris 11
solaris 11 change timezone without reboot
change timezone solaris 11
solaris 11 set time
solaris 11 set timezone
solaris timezone list
solaris change time
solaris 11 change timezone without reboot

solaris timezone
~

Popular Posts