Jump to content


Photo

timestamp


  • Please log in to reply
3 replies to this topic

#1 tecdesign

tecdesign
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 26 April 2006 - 07:44 AM

how do I turn a time stamp when posted looks like this 20060426152138 into something readable like
26th 04 2006 15:21pm or something that looks good.

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 26 April 2006 - 08:30 AM

echo date("l jS \of F Y h:i:s A", $timestamp);
Check the date() page in the manual for more information on how to format it.

#3 tecdesign

tecdesign
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 26 April 2006 - 06:27 PM

[!--quoteo(post=368761:date=Apr 25 2006, 08:30 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Apr 25 2006, 08:30 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
echo date("l jS \of F Y h:i:s A", $timestamp);
Check the date() page in the manual for more information on how to format it.
[/quote]

In my database it reads this 20060427062251 which is right but in website it is posting 19 01 38 which is d m y which in long form it goes to tuesday 19th of january 2038? Does anyone know what could be causing this?

#4 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 26 April 2006 - 06:52 PM

I think we got our wires crossed on the whole timestamp thing - I just glanced at your timestamp and assumed it was a *NIX timestamp. Upon looking at it in more detail it looks like its just the year, month, date, hour, minute and second all in one string... In which case you can just chop it up with substr() I guess, unless theres a function that does this for you, I cant think of one off the top of the head.
<?php
$str = "20060426152138";
$year = substr($str,0,4);
$month = substr($str,4,2);
$day = substr($str,6,2);
$hour = substr($str,8,2);
$minute = substr($str,10,2);
$second = substr($str,12,2);
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users