Jump to content

Converting UNIX Timestamp to regular Date display


Ernie_73

Recommended Posts

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

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.