Jump to content

Archived

This topic is now archived and is closed to further replies.

brown2005

date

Recommended Posts

[url=http://php.net/date]date[/url]().

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
could u show me some code please wildteen... ive been trying and i cant get it to work...

$date = $blog_array[blog_date];

Share this post


Link to post
Share on other sites
[code]
<?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;
}
?>
[/code]

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.

Share this post


Link to post
Share on other sites

×

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.