Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Formatting Dates example 01 - January

Posted on 2004-04-02
3
Medium Priority
?
292 Views
Last Modified: 2006-11-17
I am trying to convert a two digit Month (01,02 etc...) to (January, February etc..)

This is what I have, but it doesn't work:

$month = "02";
$date = strtotime($month);
$New_Month = date("F",$date);

Can anyone help? Thanks
0
Comment
Question by:Zambian4eva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 10742559
change your middle line to something like

$date = strtotime($month . "/01/01");
0
 
LVL 5

Accepted Solution

by:
crazycomputers earned 200 total points
ID: 10743475
What you could do is something like this..

<?php

$_months = array('January', 'February', 'March', 'April', 'May', 'June', 'July',
                           'August', 'September', 'October', 'November', 'December');

// Note that _months is zero-based...
$month = $_months[$month - 1];

?>
0
 
LVL 1

Expert Comment

by:noy_ipunk
ID: 10773245
Well, I would do it with smt like this :

$mth = 14;  //for example..skips december and go back to january

//you must fill in all the arguments if you want to make use of date function ;)
$month = date("F", mktime(0, 0, 0, $mth+1 , 0 ,0));  //plus 1 because month's array starts from 0

echo "month number is= $mth and month name is  $month ";

//result will be : month number is= 14 and month name is February
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question