Jump to content


Photo

date


  • Please log in to reply
4 replies to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 17 August 2006 - 03:41 PM

change

2006-05-31

as it comes out of the database to say

Monday 31st May 2006

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 03:42 PM

date().

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 17 August 2006 - 03:44 PM

Well you'll want to use strtotime to convert 2006-05-31  into a timestamp and then use the date function convert 2006-05-31 into the date format you want.

#4 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 18 August 2006 - 07:36 AM

could u show me some code please wildteen... ive been trying and i cant get it to work...

$date = $blog_array[blog_date];

#5 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 18 August 2006 - 08:08 AM

<?php
function parsedate($date){
  $str = strtotime($date);
  $today = date('Y-m-d');
  $todaystr = strtotime($today);
  $diff = $todaystr-$str;
  $newdate = date('l jS \of F Y',time()- $diff);
  return $newdate;
}
?>

Im not sure if it is necessary to use this:
  $today = date('Y-m-d');
  $todaystr = strtotime($today);

Perhaps i could have simpy used the time() function, but i wasn't sure if i may run into problems given that the format of the date being passed to the function is the Y-m-d and as such will not include the time for any hours during that day.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users