can anybody tell me what format of date 1311048886 is? how we insert and select in database.

Dani AI

Generated

Short answer: the numeric value is an epoch-seconds timestamp (see replies by and ). Practical guidance for working with that value in MySQL:

Store: three common choices — keep the raw integer (INT UNSIGNED) if you want compact, language-agnostic storage; use DATETIME for a fixed wall‑clock value that does not change with time zone; or use TIMESTAMP when you want MySQL to convert to/from the connection time zone automatically. Consider range: TIMESTAMP is limited compared with DATETIME, so pick DATETIME for long-term/very old/future dates. See MySQL docs for details on types and ranges MySQL date/time types.

Convert in queries: use MySQL conversion functions to display or to insert; for example, to turn the integer into a readable DATETIME in a SELECT:

SELECT FROM_UNIXTIME(1311048886) AS created_at;

To insert into a DATETIME column you can either convert on the client before sending a formatted string, or use FROM_UNIXTIME(?) in the INSERT. Index the column you query by range.

Notes and cautions: store values consistently in UTC and convert to local time only for display (PHP has timezone settings that affect formatting — see PHP timezones). If you expect dates beyond the TIMESTAMP range or need millisecond precision, choose DATETIME (or a larger numeric type) and document the format.

Recommended Answers

All 2 Replies

Member Avatar for Member #120589

Unix timestamp. Youcanuse php: time() for current timestamp

Strtotime() another useful one

Mysql:

UNIX_TIMESTAMP()

As ardav says it is a Unix timestamp and if you want to change it into a date format:

$date = date('Y-m-d', time());
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.