Displaying current date time of EDT in IST time | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

Displaying current date time of EDT in IST time

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-16-2013
Showdown Showdown is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 8 July 2014, 10:00 AM EDT
Posts: 38
Thanks: 1
Thanked 1 Time in 1 Post
Oracle Displaying current date time of EDT in IST time

Hi Folks,

My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST.

IST time leads 9:30 mins to EDT. and i wrote something like below.

timestamp=`date --date='+9 hour 30 minutes' '+%d/%b/%y %r'`


But The EDT time difference changes to 10 hrs on change of Daylight in every 6 months. How to dynamically do that.. Please Advice.



Thx in Advance...
Sponsored Links
    #2  
Old 03-16-2013
RudiC RudiC is online now Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 30 October 2014, 8:55 AM EDT
Location: Aachen, Germany
Posts: 4,473
Thanks: 73
Thanked 1,095 Times in 1,031 Posts
What about using the TZ variable. Not sure it would help with that daylight saving problem; you may need to schedule a cron job to adapt TZ every 6 months.
Sponsored Links
    #3  
Old 03-16-2013
Showdown Showdown is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 8 July 2014, 10:00 AM EDT
Posts: 38
Thanks: 1
Thanked 1 Time in 1 Post
Oracle

I would have tried the crontab . But its not a fixed date on which the day light saving lag happens....

Many Thanks for ur Quick response.
    #4  
Old 03-16-2013
Don Cragun's Avatar
Don Cragun Don Cragun is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 30 October 2014, 3:11 AM EDT
Location: San Jose, CA, USA
Posts: 4,927
Thanks: 184
Thanked 1,651 Times in 1,402 Posts
Since India does not waste time with daylight saving time shifts, just setting TZ=IST-5:30 will give you the correct time in India at any time of year. For example, a few seconds ago:

Code:
TZ=GMT0 date;TZ=IST-5:30 date

produced the output:

Code:
Sat Mar 16 11:10:49 GMT 2013
Sat Mar 16 16:40:49 IST 2013

The Following User Says Thank You to Don Cragun For This Useful Post:
chidori (03-16-2013)
Sponsored Links
    #5  
Old 03-16-2013
Showdown Showdown is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 8 July 2014, 10:00 AM EDT
Posts: 38
Thanks: 1
Thanked 1 Time in 1 Post
Oracle

Thanks Don,

Worked perfectly.
Sponsored Links
    #6  
Old 03-16-2013
chidori chidori is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 3 December 2013, 12:16 PM EST
Posts: 215
Thanks: 51
Thanked 3 Times in 3 Posts
Quote:
Originally Posted by Don Cragun View Post
Since India does not waste time with daylight saving time shifts, just setting TZ=IST-5:30 will give you the correct time in India at any time of year. For example, a few seconds ago:

Code:
TZ=GMT0 date;TZ=IST-5:30 date

produced the output:

Code:
Sat Mar 16 11:10:49 GMT 2013
Sat Mar 16 16:40:49 IST 2013

wow..!! , i did not know that shell has the ability to treat first one as variable assignment and next one it expands into a command. Thats a new thing i learnt today. Thank you
Sponsored Links
    #7  
Old 03-16-2013
Don Cragun's Avatar
Don Cragun Don Cragun is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 30 October 2014, 3:11 AM EDT
Location: San Jose, CA, USA
Posts: 4,927
Thanks: 184
Thanked 1,651 Times in 1,402 Posts
Quote:
Originally Posted by chidori View Post
wow..!! , i did not know that shell has the ability to treat first one as variable assignment and next one it expands into a command. Thats a new thing i learnt today. Thank you
Both are variable assignments, but since they are at the beginning of a command (not complete commands on their own), the settings only affect affect the environment of the command being run. They do not affect the current shell execution environment. For example:

Code:
$ TZ=PST8PDT
$ date;TZ=IST-5:30 date;date
Sat Mar 16 07:13:53 PDT 2013
Sat Mar 16 19:43:53 IST 2013
Sat Mar 16 07:13:53 PDT 2013
$ echo $TZ
PST8PDT
$

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Adding hours and minutes to current date (Only to date not to time) manojgarg UNIX for Dummies Questions & Answers 4 08-22-2012 10:50 AM
How far is given date from current time? SkySmart Shell Programming and Scripting 2 06-14-2012 12:06 AM
compare file modification date/time to current date/time Bill Ma Shell Programming and Scripting 5 08-27-2009 12:02 PM
problem with displaying date and adding time FuncMx Shell Programming and Scripting 1 10-10-2008 12:06 AM
Get date and time for past 1 hour from current date spch2o Shell Programming and Scripting 5 08-29-2008 04:32 AM



All times are GMT -4. The time now is 08:57 AM.