LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-29-2013, 02:00 AM   #1
kanishka.dutta
LQ Newbie
 
Registered: Dec 2012
Posts: 11

Rep: Reputation: Disabled
localtime and localtime_r


I would like to know the difference between localtime and localtime_r
 
Old 05-29-2013, 02:18 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
1. Open a terminal.
2. Type the following:
Code:
man localtime
3. Read what it says to the very end and you will have your answer.

jdk
 
1 members found this post helpful.
Old 05-29-2013, 02:18 AM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

localtime_r() takes a second argument that has the return value. From the man page:
Code:
       The  localtime() function converts the calendar time timep to broken-down time repre‐
       sentation, expressed relative to the user's specified timezone.  The function acts as
       if  it  called tzset(3) and sets the external variables tzname with information about
       the current timezone, timezone with the difference between Coordinated Universal Time
       (UTC) and local standard time in seconds, and daylight to a nonzero value if daylight
       savings time rules apply during some part of the year.  The return value points to  a
       statically  allocated struct which might be overwritten by subsequent calls to any of
       the date and time functions.  The localtime_r() function does the  same,  but  stores
       the data in a user-supplied struct.  It need not set tzname, timezone, and daylight.
Evo2.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
sleep & localtime query nsvora Linux - General 1 06-29-2009 11:49 PM
/etc/localtime and /etc/timezone JockVSJock Linux - Newbie 1 05-01-2009 02:33 PM
localtime() function is having problem lovelylinux Linux - Software 1 09-21-2007 02:09 AM
localtime + perl kshkid Programming 4 03-22-2007 10:55 AM
SIGSEGV for localtime_r call dragondad Linux - Software 0 08-15-2005 01:23 PM


All times are GMT -5. The time now is 08:32 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration