Script to convert GMT to Asia/Hong Kong time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to convert GMT to Asia/Hong Kong time
# 1  
Old 03-19-2008
Data 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..
# 2  
Old 03-19-2008
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

# 3  
Old 03-19-2008
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!!!!!
# 4  
Old 03-19-2008
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
}

# 5  
Old 03-19-2008
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...... Smilie) and ur rite it doesnt effect system time...
# 6  
Old 03-19-2008
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!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Convert GMT date and time to CST

I need away to convert the following GMT date and time value RAW_TME= 042720171530 "mmddccyyhhmm" to Localhost time. In this case it is in central time. Here is what I came up with but it does not look efficient: RAW_TME=042720171530 logmm=`echo $RAW_TME | cut -c1-2` logdd=`echo $RAW_TME |... (4 Replies)
Discussion started by: mrn6430
4 Replies

2. Shell Programming and Scripting

Local time to GMT time

Gents, Please can help with this. the column in red is the local time the column in blue is the GPStime 4153152529951 2/12/17 12:00:04.980 951 2960 41531.0 52529.0 1170882022980002 4108153261942 2/12/17 12:00:07.944 942 2959 41081.0 53261.0 1170882025944002 41511523611660... (7 Replies)
Discussion started by: jiam912
7 Replies

3. Shell Programming and Scripting

GMT to local Time conversion

How can I convert the following date format: New Log Date = 2016-12-30 23:50:33 GMT from GMT time to local time? Thanks (13 Replies)
Discussion started by: mrn6430
13 Replies

4. Post Here to Contact Site Administrators and Moderators

Server Upgrade Scheduled for Today - 7:30 GMT (2:30 PM Eastern Time)

Dear All, Today, somewhere around 7:30 GMT (2:30 PM Eastern Time) www.unix.com will go down for what we hope is around 15 - 20 minutes as we change out some hardware on the server. Thank you for your patience and support. Neo (0 Replies)
Discussion started by: Neo
0 Replies

5. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

6. Solaris

Installing Hong Kong Locale

Any help appreciated. I am connecting (FTP) to a NAS PRO box that is currently installed on one of our subnets in Hong Kong from a Solaris system running Solaris 10 (our backup server). The NAS box has a backup job that backs up all user documents locally. I am trying to ftp the docs from the NAS... (4 Replies)
Discussion started by: jamba1
4 Replies

7. Shell Programming and Scripting

Script to add time convert to seconds

Hi, What i am looking for and i am new to this too, is a bash script that will add time in the format hh:mm:ss and produce the answer in minutes or seconds. It needs to be a loop since there are hundreds of times in my file. This is data is from a CDR that calculates duration of time used. ... (2 Replies)
Discussion started by: trotella
2 Replies

8. HP-UX

change time mode from BST to GMT

I want to know how to change the time zone from BST to GMT avoid the daylight savings in hp-ux (3 Replies)
Discussion started by: tomjones
3 Replies

9. Solaris

Setting TImezone fr Hong kong

Hi, In solaris how to change the timezone to display to HKT I tried by putting TZ=Hongkong or TZ=Asia/Hong_kong but it is taking me to the display of CST. how to change it to HKT thanks Bala (1 Reply)
Discussion started by: Balamurugan
1 Replies
Login or Register to Ask a Question