mktime() output not the same as the date utility

Jeremy Chadwick koitsu at FreeBSD.org
Tue Oct 14 10:50:43 PDT 2008


On Tue, Oct 14, 2008 at 12:43:54PM -0400, Mark B. wrote:
> I can't figure out from the man pages why
> mktime() is giving a different result than date -f.
> Both strptime and mktime are supposed to use the
> local timezone, as does date.
> 
> The output of date is correct; mktime() is an hour later.
>
> What am I missing here?

I'm betting it's due to DST

I believe you have to do the math yourself if tm_isdst is non-zero.
Otherwise, consider using functions like ctime() and others (which are
also POSIX compliant).

-- 
| Jeremy Chadwick                                jdc at parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |



More information about the freebsd-questions mailing list