Trevors Posted April 18, 2006 Share Posted April 18, 2006 Heya allIm pretty new to php and im trying to code my own blog and im having problem printing date but a bit differently.Like this(0) April 2006 (5) March 2006 (3) February 2006 (6) January 2006 (2) December 2005 (1) November 2005 (0) October 2005 (5) September 2005 (2) August 2005 (1) July 2005 (4) thats how many blog entries there is that month.My date string looks like this "2006-01-01 01:11:11"I had a look at preg_split and integer but didnt understand much i would appreciate it very much if someone could help me out im kinda stuck big time hehe.Best RegardsTrevors Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 18, 2006 Share Posted April 18, 2006 Take a look at the [a href=\"http://www.php.net/strtotime\" target=\"_blank\"]strtotime()[/a] and [a href=\"http://www.php.net/date\" target=\"_blank\"]date()[/a] functions.[code]<?php$blog_date = '2006-01-01 01:11:11';$cnt = 6;echo '(' . $cnt . ') ' . date('F Y',strtotime($blog_date)) . '<br>';?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
ypirc Posted April 18, 2006 Share Posted April 18, 2006 That looks like a MySQL timestamp, so if it is, you should format it within MySQL. You can do this with the following: [a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/dat...-functions.html[/a][!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]mysql[color=orange]>[/color] [span style=\'color:blue;font-weight:bold\']SELECT[/span] DATE_FORMAT(NOW(), [color=red]'%M %Y'[/color]);[color=orange]+[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]+[/color]| DATE_FORMAT(NOW(), [color=red]'%M %Y'[/color]) |[color=orange]+[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]+[/color]| April 2006 |[color=orange]+[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]-[/color][color=orange]+[/color]1 row [color=green]in[/color] set (0.00 sec) [!--sql2--][/div][!--sql3--]Replace NOW() with the name of your date column. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.