tags:

views:

61

answers:

6

Hello People, I'am using UserCake for UserManagement - in the table userCake_Users there is a column "LastSignIn" but the value is in this format: 1286066935

with this function I get the right Date

public function updateLastSignIn()
{
    global $db,$db_table_prefix;

    $sql = "UPDATE ".$db_table_prefix."Users
            SET
            LastSignIn = '".time()."'
            WHERE
            User_ID = '".$db->sql_escape($this->user_id)."'";

    return ($db->sql_query($sql));
}

but which format is 1286066935?

this is the sql file

--
-- Table structure for table `Users`
--

CREATE TABLE IF NOT EXISTS `Users` (
  `User_ID` int(11) NOT NULL auto_increment,
  `Username` varchar(150) NOT NULL,
  `Username_Clean` varchar(150) NOT NULL,
  `Password` varchar(225) NOT NULL,
  `Email` varchar(150) NOT NULL,
  `ActivationToken` varchar(225) NOT NULL,
  `LastActivationRequest` int(11) NOT NULL,
  `LostPasswordRequest` int(1) NOT NULL default '0',
  `Active` int(1) NOT NULL,
  `Group_ID` int(11) NOT NULL,
  `SignUpDate` int(11) NOT NULL,
  `LastSignIn` int(11) NOT NULL,
  PRIMARY KEY  (`User_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+1  A: 

It's UNIX time: http://en.wikipedia.org/wiki/Unix_time

The time()-function in php (assuming that's what you're using) returns the time in the very same format, for example.

Jakob
A: 

Probably UNIX time. Number of seconds since 01/01/1970.

Thomas
+2  A: 

My guess is it's a UNIX Timestamp.

colithium
ok thank you, great! is this format good? or should I convert it to another format? I will accept your answer in 10 minutes. thanks
elmanino
It's a widely used format. But typically in a DB you'd use a DATETIME column instead of the raw INT value (even though it can be represented as an INT just fine)
colithium
FWIW, the UNIX timestamp format is not good for dates past 2038-01-19. I recommend using DATETIME too.
Bill Karwin
The advantage of using a timestamp is you don't have to worry about what your database or data access layer is going to do with date formatting and timezones. You can of course use a larger integer type to get a longer range of values.
bobince
+2  A: 

but which format is 1286066935?

It's Unix time. It's the number of seconds since midnight GMT on 1st January 1970.

1286066935 represents 00:48:55 GMT today, 3rd October 2010.

You can convert a Unix timestamp to an 'ordinary' date/time using an online converter like this one. Alternatively you can use the date command, on Linux:

$ date -d @1286066935
Sun Oct  3 01:48:55 BST 2010
Richard Fearn
+2  A: 

It's called a Unix Time Stamp

Basically, in Unix time stamps are represented as the number of seconds from the Unix Epoch or Jan 1, 1970

Noah Goodrich
+1  A: 

Looks like a UNIX timestamp to me (number of seconds since 1st January 1970.)

Assuming you're using PHP based on that code snippet, you can use the time() function to return the current UNIX timestamp for insertion into your database.

If you wanted to do the processing with your MySQL query, take a look at the UNIX_TIMESTAMP() function.

chigley