Welcome Guest, Not a member yet? Register   Sign In
Blog Archives
#1

[eluser]Yash[/eluser]
I've date values in a field ex

2008-06-11 02:07:08

2007-02-23 14:11:11

2007-02-06 14:11:11

Now I need to convert these into text

like

June 2008
Feb 2007 and like so...

Is there any direct function for this.Or I need to write a function.

Thank you
#2

[eluser]Pascal Kriete[/eluser]
Where are you getting this string from? I find it easiest to work with unix timestrings.

Php has a function strtotime to get a unix timestamp from a string if you don't have a unix representation. Then you can use the date function to re-format it.
#3

[eluser]Yash[/eluser]
Code:
$query = $this->db->query('select DISTINCT PostedDate from posts');
          foreach ($query->result() as $row)
            {    $input[]= date("F Y ",strtotime($row->PostedDate)); }
            
            
          

            $result = array_unique($input);
            var_dump($result);
Output is

array(3) { [0]=> string(11) "April 2003 " [1]=> string(14) "February 2003 " [3]=> string(10) "June 2008 " }

Now I want April 2003 contains a link like www.site.com/blog/2003-04

How to achieve that and Is this a right way to do..
#4

[eluser]Yash[/eluser]
Complete working function

Code:
$query = $this->db->query('select DISTINCT PostedDate from posts');
  foreach ($query->result() as $row)
  {

  $input[]= "<a >PostedDate,0,7)."\">".date("F Y ",strtotime($row->PostedDate))."</a>";
            
            
}

$result = array_unique($input);
print_r($result);




Theme © iAndrew 2016 - Forum software by © MyBB