mcmuney Posted September 15, 2006 Share Posted September 15, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/20920-date-display/ Share on other sites More sharing options...
AndyB Posted September 15, 2006 Share Posted September 15, 2006 How was 1158340157 generated in the first place? Quote Link to comment https://forums.phpfreaks.com/topic/20920-date-display/#findComment-92673 Share on other sites More sharing options...
kenrbnsn Posted September 15, 2006 Share Posted September 15, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/20920-date-display/#findComment-92755 Share on other sites More sharing options...
pkSML Posted September 16, 2006 Share Posted September 16, 2006 If you'd like to display MM-DD-YYYY at HH:MM:SS, try this code:[code]<?phpecho date("m-d-Y \a\\t H:i:s",$rs_mem[$i][date_added]);?>code][/code] Quote Link to comment https://forums.phpfreaks.com/topic/20920-date-display/#findComment-92800 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.