开发者

Don't understand the date format in mysql like 1286066935 - UserCake

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 ;


My guess is it's a UNIX Timestamp.


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


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


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜