Changing the date to EST


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing the date to EST
# 1  
Old 07-14-2006
Changing the date to EST

Hi,

The unix box has a system date in the PDT time zone format..if i need to capture the value of the date in a variable id do this:
orderdate=`date '+%Y%m%d'`
ordertime=`date '+%H%M%S'`

output :
$orderdate= 20060714
$ordertime= 043438

I need to convert and store this orderdate and ordertime to EST format.Is there any functions that let me get the EST timezone value instead of jst adding 3 hours???
shiroh_1982
# 2  
Old 07-14-2006
The environment variable TZ can be used to change the timezone temporarily
I'm assuming you are in the Pacific timezone (TZ="PST8PDT") in this code snippet:
Code:
#!/bin/ksh
oldTZ="$TZ"
export TZ="EST5EDT"
orderdate=`date '+%Y%m%d'`
ordertime=`date '+%H%M%S'`
export TZ="$oldTZ"

# 3  
Old 07-17-2006
thanks worked perfectly
shiroh_1982
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Changing CSV files with date . Subtracting date by values

Hi All, I have a CSV file which is as below. Basically I need to take the year column in it and find if the year is >= 20152 . If that is then I should subtract all values by 6. In the below example in description I am having number mentioned as YYWW so I need to subtract those by -5. Whereever... (8 Replies)
Discussion started by: arunkumar_mca
8 Replies

2. Shell Programming and Scripting

changing date to resemble "messages file" date

the following was taken from a perl script: my $date = strftime "%B %d %H:%M:%S", localtime; how can i modify it so this date outputs the date in the form of the date of the messages file. for example: Sep 20 11:48:44 As it is right now, the perl script outputs the date like this: ... (1 Reply)
Discussion started by: SkySmart
1 Replies

3. Shell Programming and Scripting

Changing the date format

Hi all, I have a file with below data af23b|11-FEB-12|acc7 ad23b|12-JAN-12|acc4 as23b|15-DEC-11|acc5 z123b|18-FEB-12|acc1 I need the output as below:-(date in yyyymmdd format) af23b|20120211|acc7 ad23b|20120112|acc4 as23b|20111215|acc5 z123b|20120218|acc1 Please help me on this.... (7 Replies)
Discussion started by: gani_85
7 Replies

4. UNIX for Advanced & Expert Users

Autosys run window in EST

Hi, I want to run a job in 5 min duration and start time should be 21:30EST and endtime should be 18:30EST nextday. in long note, it will start from sunday 21:30EST to monday 18:30EST......monday 21:30 EST to tuesday 18:30 EST....tuesday 21:30 ESTto wednesday 18:30EST...wednesday 21:30EST to... (1 Reply)
Discussion started by: millan
1 Replies

5. Shell Programming and Scripting

JavaScript to get Timezone (IST, EST, etc)

Friends, I am trying to write a Javascript to get the local timezone (not UTC+5.30, etc but exactly like IST, PST, etc). I been trying for two days and I am finally here to ask for some pointers. I did googling and found the getTimezoneOffset function as well but I can not make use of it to get... (1 Reply)
Discussion started by: dahlia84
1 Replies

6. Shell Programming and Scripting

Changing date regularly..

Hi Guys, Plzz help me out in this!!!!!!!!!!!!!!!! I have a file which runs in the back ground using crontab for every monday at5 P.M. The problem is inside the file ... This is a sample content of a file Update the current and previous week: (Sunday to Sunday) %let... (4 Replies)
Discussion started by: aajan
4 Replies

7. Linux

changing date

Hi, I want to create one user who has right to change the date in linux, (1 Reply)
Discussion started by: manoj.solaris
1 Replies

8. UNIX for Dummies Questions & Answers

Changing Creation Date to a Prespecified Date of a File In Unix

Dear Expert, Is there a command to do that in Unix? In such a way that we don't need to actually "write" or modified the content. -- monkfan (4 Replies)
Discussion started by: monkfan
4 Replies

9. UNIX for Dummies Questions & Answers

Changing date per session

Hello Can user change his date ( date -u ) and not being as root? i need it for testing. (1 Reply)
Discussion started by: umen
1 Replies

10. UNIX for Dummies Questions & Answers

changing the date

I need to change the date of the UNIX server at work to 20 aug 2001. How do I do this? And will this affect any databases running, or do I need to bring all databases down? (2 Replies)
Discussion started by: JBX
2 Replies
Login or Register to Ask a Question