Ernie_73 Posted June 19, 2011 Share Posted June 19, 2011 Hello World, I use a new PHP Shoutbox Setup on one of my Homepages. It works well so far, but it does not display the date when the post has been made, when displaying the post on the page. This is the first time for me working with PHP, so far, I only know Perl programming. the configuration lines look like: --- $date = date('M-d-Y / g:i'); $time = mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y')); --- The Script Line to create the Posts looks like this: --- echo "<strong>".base64_decode($mess2[$i][1]).": </strong><span title=\"".base64_decode($mess2[$i][4])."\"> ".base64_decode($mess2[$i][2]); --- The Command: --- echo ".base64_decode($mess2[$i][5])." --- would result in displaying the UNIX Time related with the indicidual Post like --- 1308441437: Samstag Abend war sie anwesend 1308416371: ist Jerin auch noch ab und zu bei euch zu besuch ? 1308403651: Danke für die Info freue mich --- but I would like to make it readable in a fashionable way. Thank you very much for assistance! Ernie Quote Link to comment https://forums.phpfreaks.com/topic/239758-converting-unix-timestamp-to-regular-date-display/ Share on other sites More sharing options...
mikesta707 Posted June 19, 2011 Share Posted June 19, 2011 you can use the date function: http://php.net/manual/en/function.date.php The second parameter accepts a unix time stamp. Check out the manual page for how to format it like you want, but here is an example $dateFromTimestamp = date("F j, Y, g:i a", $timestamp); // March 10, 2001, 5:16 pm (for example) Quote Link to comment https://forums.phpfreaks.com/topic/239758-converting-unix-timestamp-to-regular-date-display/#findComment-1231633 Share on other sites More sharing options...
Ernie_73 Posted June 19, 2011 Author Share Posted June 19, 2011 thank you for your info. Sorry, I am not english origin, so, my problem is that I do not know how to handle the Unix Date- information, which is called by this line: ".base64_decode($mess2[$i][5])." because it will only produce the UNIX 10 digit output. I need to know how to create and declare a PHP $value out of it, in order to place this $value as the first information of each post. The $value name could eventually be: $postdate As a result of this, the Output Line would look like: echo "$postdate <strong>".base64_decode($mess2[$i][1]).": </strong><span title=\"".base64_decode($mess2[$i][4])."\"> ".base64_decode($mess2[$i][2]); instead of; echo "<strong>".base64_decode($mess2[$i][1]).": </strong><span title=\"".base64_decode($mess2[$i][4])."\"> ".base64_decode($mess2[$i][2]); as it is in it's original form, without and posting-date information on screen. I am sure it's real easy to declare something like this, but so for a php newbe, it's a real secret... Ernie Quote Link to comment https://forums.phpfreaks.com/topic/239758-converting-unix-timestamp-to-regular-date-display/#findComment-1231912 Share on other sites More sharing options...
Ernie_73 Posted June 19, 2011 Author Share Posted June 19, 2011 I have solved most of the problem this way: $variable ="".base64_decode($mess2[$i][4]).""; echo "$variable Uhr<br /> <strong>".base64_decode($mess2[$i][1]).": </strong><span title=\"".base64_decode($mess2[$i][4])."\"> ".base64_decode($mess2[$i][2]); to now display: --- Jun-20-2011 / 1:37 Uhr Ernesto: das ist ein test Jun-19-2011 / 2:18 Uhr Ernesto: Wir werden ab Juli wieder eine Art Liste publizieren --- the only matter unsolver is now how to modify the -variable in order to display european time like "20.6.2011" or so !? thank you Ernie Quote Link to comment https://forums.phpfreaks.com/topic/239758-converting-unix-timestamp-to-regular-date-display/#findComment-1231961 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.