Jump to content

Archived

This topic is now archived and is closed to further replies.

mcmuney

Date Display

Recommended Posts

I'm sure this is very simple, but confusing to me.. how to display date in various formats. My database stores date as "1158340157" and when i display with this code [code]<?=$rs_mem[$i][date_added]?>[/code]

How and where do I specify the format of this?

Share this post


Link to post
Share on other sites
How was 1158340157 generated in the first place?

Share this post


Link to post
Share on other sites
That looks like a UNIX timestamp. To convert it into something readable, use the [url=http://www.php.net/date]date()[/url] function.

[code]<?php
$nd = 1158340157;
echo date('Y-m-d',$nd);
?>[/code]

Ken

Share this post


Link to post
Share on other sites
If you'd like to display MM-DD-YYYY at HH:MM:SS, try this code:

[code]
<?php
echo date("m-d-Y \a\\t H:i:s",$rs_mem[$i][date_added]);
?>
code][/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.