The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
time convert b_manu78 AIX 10 3 Weeks Ago 10:47 AM
Convert milliseconds to standard time chiru_h Shell Programming and Scripting 1 07-19-2007 10:45 AM
Setting TImezone fr Hong kong Balamurugan SUN Solaris 1 02-10-2006 06:05 AM
Convert UTC time to Date GNMIKE Shell Programming and Scripting 8 10-19-2005 11:43 PM
Convert from standard epoch time from a shell script? LordJezo Shell Programming and Scripting 4 09-18-2005 08:48 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-19-2008
Registered User
 

Join Date: Mar 2008
Location: NY
Posts: 6
Stumble this Post!
Unhappy Script to convert GMT to Asia/Hong Kong time

hi friends,
this is my first time with this type of script so please pardon my ignorance. i have this script in which a piece of code needs to be added which can have the Asia/Hong kong time as well. system date and format is GMT so no problem with GMT and even EST is covered..i have ato add new File watchers and that requires an update to the following script to support Asia time as well.


#!/bin/sh
LOGS=/etdhub-as1/apps/home/pcent/informatica/logs
EDATE=`date "+%Y%m%d_%T"`
BIN=/etdhub-as1/apps/home/pcent/informatica/Scripts
UNIXSERVER=etdhub-as1-p.prd.etsd.ml.com
ETC=/etdhub-as1/apps/home/pcent/etc
TMP=/etdhub-as1/apps/home/pcent/tmp

export LOGS EDATE BIN UNIXSERVER ETC TMP

WOMBATDIR=/gfs/data/.../prod/wombatsymbolfiles/1.0
SRCDIR=/gffgf/apps/home/pcent/informatica/SrcFiles/OPTIONS_Delivery
ROPADIR=/gfs/data/sss/prod/ropa/1.0
LIFDIR=/gfs/data/sss/raw/liffe
FOWDIR=/gfs/data/sss/prod/fowtradedata
GMTDATE=`date "+%Y%m%d"`
GDATE=`date "+%Y%m%d_%T"`
GYEAR=`date "+%Y"`
GMONTH=`date "+%m"`
GDD=`date "+%d"`

TAIWANDIR=/gfs/data/sss/raw/taiwandata
TDATE=`date "+%Y%m%d"`
TYEAR=`date "+%Y"`
TMONTH=`date "+%m"`
TDD=`date "+%d"`


export WOMBATDIR SRCDIR ROPADIR GDATE GYEAR GMONTH GDD FOWDIR LIFDIR GMTDATE TAIWANDIR TDATE TYEAR TMONTH TDD

STOCKLOANDIR=/gfs/data/sss/raw/stockloan
SDATE=`date "+%Y%m%d"`
SYEAR=`date "+%Y"`
SMONTH=`date "+%m"`
SDD=`date "+%d"`


any help would be much appreciated..
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-19-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,846
Stumble this Post!
IF you on a POSIX compliant system you can use the TZ variable. This machine is CST.
It doesn't have a TZTAB entry (HPUX thing for timezones) for Hong Kong but it doesn't matter. I am assuming HK is UTC+8:
Code:
csadev:/home/jmcnama> date +%c
Wed Mar 19 11:49:58 2008
csadev:/home/jmcnama> echo $TZ
CST6CDT
csadev:/home/jmcnama> TZ=HST-8HST
csadev:/home/jmcnama> date +%c
Thu Mar 20 00:51:52 2008
Reply With Quote
  #3 (permalink)  
Old 03-19-2008
Registered User
 

Join Date: Mar 2008
Location: NY
Posts: 6
Stumble this Post!
i dont want to change the server time...i wanted to add some script to mine so if i use this file it will support Asia time also..server time should stay as it is (GMT)...any thoughts!!!!!
Reply With Quote
  #4 (permalink)  
Old 03-19-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,846
Stumble this Post!
TZ is a per process thing, set it back to EST5EDT or whatever when you are done in the script. This DOES NOT AFFECT SYSTEM TIME.

Code:
hong_kong()
{
   TZ=HST-8HST
   date "+%c"
   TZ=CST6CDT
}
Reply With Quote
  #5 (permalink)  
Old 03-19-2008
Registered User
 

Join Date: Mar 2008
Location: NY
Posts: 6
Stumble this Post!
if I have to change it form GMT would it still be "TZ=HST-8HST" or "TZ=HST-7HST" since the day light time came into effect?
Otherwise it works...Really eally appreciate it...... ) and ur rite it doesnt effect system time...
Reply With Quote
  #6 (permalink)  
Old 03-19-2008
Registered User
 

Join Date: Jul 2007
Posts: 93
Stumble this Post!
you didn't specify which OS your using, so you'd want to doublecheck what
the timezone entry is for Hongkong, just to be safe.
Solaris is TZ=Hongkong

if I have to change it form GMT would it still be "TZ=HST-8HST" or "TZ=HST-7HST" since the day light time came into effect?

No, the system will know how to compensate for EST or DST with the default entry.

PS: Hongknog does not use day light saving time!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
solaris

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0