|
-
Ex-***
MYSQL Timestamp
Yo! How are you all doing? 
How do I display the TIMESTAMP in a more readable way instead of just a bunch of numbers?
Using PHP, I'd like to somehow tell it that the first two numbers are the year, the next are month etc, so that it could look more like this:
01.05.2003, 22:39 instead of 0305012239
Now listening to various rock and metal
143rd member to join Sharkyforums.
-
Ursus Arctos Moderatis
I would use MySQL's built-in UNIX_TIMESTAMP function, which will return a unix-timestamp from a MySQL-timestamp. You could then use php's date() function to format it how you'd like.
UNIX_TIMESTAMP(date)
If called with no argument, returns a Unix timestamp (seconds since '1970-01-01 00:00:00' GMT) as an unsigned integer. If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' GMT. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD in local time:
mysql> SELECT UNIX_TIMESTAMP();
-> 882226357
mysql> SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00');
-> 875996580
When UNIX_TIMESTAMP is used on a TIMESTAMP column, the function will return the internal timestamp value directly, with no implicit ``string-to-unix-timestamp'' conversion. If you pass an out-of-range date to UNIX_TIMESTAMP() it will return 0, but please note that only basic checking is performed (year 1970-2037, month 01-12, day 01-31). If you want to subtract UNIX_TIMESTAMP() columns, you may want to cast the result to signed integers. See section 6.3.5 Cast Functions.
-
Ex-***
thanks. I decided to just use a varchar field instead and use the date() function.
Now listening to various rock and metal
143rd member to join Sharkyforums.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|