Connecting Tech Pros Worldwide Forums | Help | Site Map

Date in custom format

Member
 
Join Date: Nov 2008
Location: Chennai, India
Posts: 100
#1: Oct 6 '09
Hi,

I have to show system date in custom format

For example: 2009/Oct/06

I want to show date in above format. how to get this output .

i used the below format
Expand|Select|Wrap|Line Numbers
  1. $months = array(1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", 12 => "Dec");
  2.  
  3. $raw_date = date("Y/m/d");
  4. list($year, $month, $day) = split('[/]', $raw_date);        
  5. $date = $year . "/" . $month . "/" . $day;
  6.  
But i struck how to apply that array format in this format?

Can any one help me how to get the custom format date using php.

Thanks in advance

Regards,

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,653
#2: Oct 6 '09

re: Date in custom format


what about
Expand|Select|Wrap|Line Numbers
  1. date("Y/M/d")
?
Member
 
Join Date: Nov 2008
Location: Chennai, India
Posts: 100
#3: Oct 6 '09

re: Date in custom format


Quote:

Originally Posted by Dormilich View Post

what about

Expand|Select|Wrap|Line Numbers
  1. date("Y/M/d")
?

in date("Y/M/d") function i am getting output as 2009/10/06.

but i want date in 2009/Oct/06. this format.

How to get this?

thanks in advance

Regards,
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,653
#4: Oct 6 '09

re: Date in custom format


Quote:

Originally Posted by phpmagesh View Post

in date("Y/M/d") function i am getting output as 2009/10/06.

you probably wrote "Y/m/d" since "Y/M/d" resulted in the desired output (I tested that!)
Attached Thumbnails
date.jpg  
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,653
#5: Oct 6 '09

re: Date in custom format


Quote:

Originally Posted by cestapassu View Post

is there any difference between M and m? Is it case sensitive?

well, obviously. haven’t you looked at date()’s formatting options? (that’s about three dozen letters)
Reply