Date Conversion

Thread Solved

Join Date: Dec 2007
Posts: 54
Reputation: rouse is an unknown quantity at this point 
Solved Threads: 1
rouse rouse is offline Offline
Junior Poster in Training

Date Conversion

 
0
  #1
Apr 26th, 2009
In a code routine I receive strings like “04242009” and I need to convert it to April 24, 2009. I have played with several of the date conversion routines but I am getting no where. Help would be appreciated.

Thanks!
WBR
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Date Conversion

 
0
  #2
Apr 27th, 2009
apply substring function
  1. $day=substr("04242009", 0, 1);
  2. $month=substr("04242009", 2, 3);
  3. $year=substr("04242009", 4, 7);
  4. $mydate=$year."-".$month."-".$day;
  5.  
  6. $converted_date=date($mydate,'F d, Y');
Last edited by BzzBee; Apr 27th, 2009 at 2:14 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 54
Reputation: rouse is an unknown quantity at this point 
Solved Threads: 1
rouse rouse is offline Offline
Junior Poster in Training

Re: Date Conversion

 
0
  #3
Apr 27th, 2009
Thanks for pointing me in the right directions. I had to make some changes to your code and this is what I finally ended up with.
WBR
  1. $chopDate =” 04242009";
  2. $month=substr($chopDate, 0, 2);
  3. $day=substr($chopDate, 2, 2);
  4. $year=substr($chopDate, 4, 7);
  5. $myDate=$month . "/" . $day . "/" . $year;
  6. $printDate = date("jS F, Y", strtotime ($myDate));
  7. print ("<h3> <center>$printDate </center></h3>");
  8.  
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Date Conversion

 
1
  #4
Apr 27th, 2009
it depends on your requirement. i didn't knew your requirement so i just gave an idea with dummy example.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC