localtime

Why LocalTime displays server time and not browser time?

I am probably doing something wrong -- but cant figure why. I have a DateTime field in my DB keeping a UTC time My server is in the US, and the browser is in Europe. The PageLoad Code is as follow: DateTime t = DateTime.SpecifyKind((DateTime)rdr["startTime"], DateTimeKind.Utc); label1.Text = t.ToLocalTime().ToString(); The time di...

Replacing time() and localtime() with user-independent equivalents

I have a program that uses time() and localtime() to set an internal clock, but this needs to be changed so that the internal clock is independent of the user and the "real" time. I need to be able to set any reasonable starting time, and have it count forward depending on a timer internal to the program. Any ideas on the best way to a...

How do I preserve localtime() as an int when printing?

I'm trying to append the integral return value of localtime (in Perl) but I can't seem to avoid it converting the return val to something that looks like this: Sun Jul 26 16:34:49 2009 When I say print localtime I see what I want, but when I say $foo = localtime,""; print $foo; I get the string. I want those digits. I tried $foo = local...

/usr/share/zoneinfo epic fail

I have just, in my groggy morning state, reversed & confused the arguments to ln, replacing /usr/share/zoneinfo/America/Toronto with a link to the non-existant /etc/localtime, when I really wanted to link /etc/localtime to Toronto. Now I have no timezone file for where I live. Does anybody have a copy or know where I could get one? It's ...

Create jodatime LocalDate from java.sql.Time

I'm new to joda-time and I didn't find anywhere examples to do some simple things. I want to make an object where to save a time value read from a table in a database (a java.sql.Time - e.g. "18:30:00") I don't care about time zone, so I think that I need LocalDate. But the problem is that I couldn't create a LocalDate object based on t...

Convert local time (10 digit number) to a readable datetime format

Hey all, I'm working with pbx for voip calls. One aspect of pbx is that you can choose to receive CDR packages. Those packages have 2 timestamps : "utc" and "local", but both seem to always be the same. Here's an example of a timestamp : "1268927156". At first sight, there seems to be no logic in it. So i tried converting it several w...

localtime_r supposed to be thread safe, but causing errors in Valgrind DRD

I searched google as much as I could but I couldn't find any good answers to this. localtime_r is supposed to be a thread-safe function for getting the system time. However, when checking my application with Valgrind --tool=drd, it consistantly tells me that there is a data race condition on this function. Are the common search results ...

How do I convert epoch time to normal time in Perl?

I am attempting to write a Perl script that parses a log where on each line the second value is the date. The script takes in three arguments: the input log file, the start time, and the end time. The start and end time are used to parse out a certain value on each line that that falls between those two times. But to properly run this...

How do I get yesterday's date using localtime?

How do I tweak this to get yesterday's date using localtime? use strict; sub spGetCurrentDateTime; print spGetCurrentDateTime; sub spGetCurrentDateTime { my ($sec, $min, $hour, $mday, $mon, $year) = localtime(); my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my $currentDateTime = sprintf "%s %02d %4d", $abbr[$mon], ...

perl- help formatting a timestamp

I am reading in log data with the following time stamp format: Sat Aug 07 04:42:21 2010 I want to convert it to something like this: 20100807044221 What is the best way to do this in perl? Thanks. ...