timestamp

What are the pros and cons of the various date/time field types in MySQL?

Date and time in MySQL can be stored as DATETIME, TIMESTAMP, and INTEGER (number of seconds since 01/01/1970). What are the benefits and drawbacks of each, particularly when developing under a LAMP stack? ...

How to Convert 64bit Long Data Type to 16bit Data Type.

I am curious to know How to Convert 64bit Long Data Type to 16bit Data Type. As this feature is required in the Ethernet Application to include Time Stamp. We left with only 2Bytes [16bits] to include Time Stamp. We get 64bit long the Time Stamp from Win API. Any answer will be highly appreciated. Thank you. ...

How to implement a "who's online" feature in PHP?

How would one go about implementing a "who's online" feature using PHP? Of course, it would involve using timestamps, and, after looking at phpBB's session table, might involve storing latest visits in a database. Is this an efficient method, or are there better ways of implementing this idea? Edit: I made this community wiki accidenta...

PEAR vs PHP time functions

Hi All I'm looking into basic time functions (creating a UTC timestamp and converting into a local timezone). The first set of tutorials i encountered pointed toward PEAR as it's better at avoiding overspill errors in calculations. Now, mid-way through another, it appears that PEAR has issues with some of it's timezone functions running...

Fix for 'return' in cakePHP to return Value from view controller funtion

Hi there I have a function inside of a view function inside of a model class in the model.php file that looks like this function sqlToUnix($date){ $YMDThenHMS = explode(" ", $date); $YMD = explode("-", $YMDThenHMS[0]); $HMS = explode(":", $YMDThenHMS[1]); $UnixTime = mktime($HMS[0], $HMS[1], $HMS[2], $YMD[1], $YMD[2], $...

Flex Date() constructor is mis-converting Unix time stamps argh

This is seriously killing me. I'm trying to convert a Unix timestamp (1236268800, which equates to Thu, 05 Mar 2009 16:00:00 GMT) to a Date object in Flex. var timestamp:Number = 1236268800; trace(new Date(timestamp)); Output: Wed Jan 14 23:24:28 GMT-0800 1970 Also tried this: var timestamp:Number = 1236268800; var date:Date = new D...

Best way to calculate dates from results?

I have a database table. It has several hundred entries and each entry is timestamped. I'm looking to only output each day and not have it duplicate any days. Data: 2009-02-04 06:20:27 2009-02-04 06:20:27 2009-02-05 06:20:27 2009-02-07 06:20:27 2009-02-07 06:20:27 2009-02-07 06:20:27 Output should only be (time is irrelevant): 20...

How to calculate the difference between two Java java.sql.Timestamps?

Please include the nanos, otherwise it would be trivial: long diff = Math.abs(t1.getTime () - t2.getTime ()); [EDIT] I want the most precise result, so no doubles; only integer/long arithmetic. Also, the result must be positive. Pseudo code: Timestamp result = abs (t1 - t2); Examples: t1 = (time=1001, nanos=1000000), t2 = (time=99...

Oracle TIMESTAMP WITH TIMEZONE named zone vs offset

In oracle, is the named timezone always stored? I have been testing this column within our system, and in some places the timestamp is shown as: 26-FEB-09 11.36.25.390713 AM +13:00 but other times it's: 26-FEB-09 11.36.25.390713 AM Pacific/Auckland If the value is being stored as the former, does that mean the actual timezone is n...

strftime( ) doesn't display the seconds correctly

I tried strftime( ) to get a formatted time-stamp. char ft[ 256 ]; struct tm *tmp; strftime( ft, 256, "%D - %T", tmp ); My problem is that I get "13/02/60 - 03:07:-17958194" as a result. Is there a way to display the seconds properly? (I'm using Mac OS X and gcc) ...

What is the smallest size of bytes that you can store a timestamp?

I want to create my own time stamp data structure in C. DAY ( 0 - 31 ), HOUR ( 0 - 23 ), MINUTE ( 0 - 59 ) What is the smallest data structure possible? ...

How do I compare unix time stamps (numbers) inside a function in PHP?

Ok, I fear that this is just me having forgotten some small stupid thing about PHP, but I just can't seem to figure out what is going on here. Test code: <?php header('Content-Type: text/plain'); $closingDate = mktime(23, 59, 59, 3, 27, 2009); function f1() { return time() > $closingDate; } function f2() { return time() <...

What's the opposite of the localtime function in Perl?

In Perl, localtime takes a Unix timestamp and gives back year/month/day/hour/min/sec etc. I'm looking for the opposite of localtime: I have the parts, and I'd like to build a unix timestamp from them. ...

System.currentTimeMillis() for a given date?

Since java.util.Date is mostly deprecated, what's the right way to get a timestamp for a given date, UTC time? The one that could be compared against System.currentTimeMillis(). ...

Ruby: Mysql timestamp/datetime problem

Is there solution for '0000-00-00 00:00:00' problem, without changing table? I have "[]" in this query: dbh.select_all("select j.n, j.name, j.dsc, j.flag, j.td from job j where j.td='0000-00-00 00:00:00'") I look solution for this: http://rubyforge.org/tracker/index.php?func=detail&amp;aid=22243&amp;group_id=234&amp;atid=967 ...

Getting Local Windows User login session timestamp in C#

Hi, I've been trying to look around the various .NET class library's for some where I can get the logged in user of the local machine, either connected to a domain or not. So far System.Security.Principal.WindowsPrincipal LoggedUser = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal; // This retu...

How can I store a timestamp in a DBM database?

I am implemening simple file-sharing service. Currently I use a file-based database (as it suits my needs). # somewhere in my cgi script sub first_run { my $dbh = DBI->connect('dbi:DBM:'); $dbh = DBI->connect("dbi:DBM:", "", "",{ AutoCommit => 1, RaiseError => 1, f_dir=>$DATABASE_DIR} ); unless ($dbh) {...

Optimal timestamp-based query in Django

What is the optimal query to obtain all the records for one specific day? In my Weather model, 'timestamp' is a standard DateTimeField. I'm currently using start = datetime.datetime(2009, 1, 31) end = start + datetime.timedelta(hours=23, minutes=59, seconds=59) Weather.objects.filter(timestamp__range=(start, end)) but wonder if there...

A PostgreSQL timestamp field not formated in the same way when updated with PHP.

I have a timestamp with timezone field in PostgreSQL. When I update this field, I use something like this: $date = date('Y-m-d H:i:s'); Although the SQL works fine, the date saved seem a little bit different to a classic timestamp with timezone date. Example: Default value set to "now()": date 2009-04-06 14:39:53.662522+02 Update ...

How do I get the entity framework to stop setting the rowversion field?

Im using the Entity Framework and I have a rowversion (timestamp) field on a table to use for concurrency. However, when updating the entity object, it keeps trying to set the rowversion column to null, and I get an error: The 'VerCol' property on 'LmpDemoRequest' could not be set to a 'null' value. You must set this property to a non-...