LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-18-2010, 10:17 AM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
getting current time zone offset


I'm looking for a function (prefer POSIX, but Linux specific would do if it has to) to get the current timezone offset. For my location, eastern USA, that should be -14400 when daylight time is in effect, and -18000 otherwise.

Language is C
 
Old 06-19-2010, 08:41 PM   #2
keithieopia
Member
 
Registered: Feb 2005
Posts: 69

Rep: Reputation: 18
For a simple command use "date". Not sure what it would output in daylight savings, but my clock doesn't sync with timeservers and it seems to be always correct:
Quote:
# date +%z
-0400
For C programming, look at the GNU C Library: http://www.cs.utah.edu/dept/old/texi...ibrary_19.html. Search for "Data Type: struct timezone" and that should give you what you're looking for.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting time and time zone altogether properly in Slack-current, KDE4 spaceballs Slackware 3 04-20-2011 05:15 AM
Run script in EST time zone but server is in GMT zone jeesun Linux - Networking 1 04-04-2010 01:37 PM
how to get time offset from time zone venkat_k Programming 4 08-28-2009 08:29 AM
Time skew of 580 min when I set my time zone in Gentoo scooter2 Linux - Newbie 1 03-05-2009 10:27 AM
StepMania - Time offset ProfEich Linux - Games 0 10-01-2005 11:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration