[43668] in North American Network Operators' Group
Re: Unix Timestamp
daemon@ATHENA.MIT.EDU (Steven M. Bellovin)
Mon Oct 22 14:58:02 2001
From: "Steven M. Bellovin" <smb@research.att.com>
To: Brandon Handeland <Brandon@wyoming.com>
Cc: nanog@merit.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Date: Mon, 22 Oct 2001 14:57:14 -0400
Message-Id: <20011022185714.187F07B55@berkshire.research.att.com>
Errors-To: owner-nanog-outgoing@merit.edu
In message <5.1.0.14.2.20011022123839.05490760@calamity.wyoming.com>, Brandon H
andeland writes:
>
>Does anyone have a formula to convert a unix time stamp into the current time?
>
>I know it is January 1st, 1970, in UTC format. Just need some example code.
>
>I'm trying to export some data from a HP/UX box into a MSSQL database and
>need to use the timestamp feature of MSSQL.
>
How accurate does your conversion need to be? Do you need timezones?
Daylight time?
On any Unix system, including the open-source clones, grab a copy of
ctime.c; its job is to do exactly that. If you want to approximate the
answer -- well, there are 86400 seconds/day, and either 365 or 366
days/year. The remaind when dividing by 86400 is the number of seconds
into the current day, in UTC.
--Steve Bellovin, http://www.research.att.com/~smb
Full text of "Firewalls" book now at http://www.wilyhacker.com