Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

GET DATE ARRAY

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

GET DATE ARRAY

Postby miguelna » Wed Sep 18, 2002 12:41 am

Somebody knows some form to obtain an Array with all dates in the MM-YY format (Example: MAR-02) between two dates, for example between MAR-99 and JUL-04?
miguelna
New php-forum User
New php-forum User
 
Posts: 15
Joined: Wed Sep 04, 2002 12:53 am

Postby Jay » Wed Sep 18, 2002 1:16 am

There's no PHP function for it as far as I am aware, you'll have to make your own. It should be simple enough though. Use a start and end date as parameters, then create a while loop that'l increment the month until it reaches the end date!
Jay
 

Postby miguelna » Fri Sep 20, 2002 3:20 am

The problem is increment the month and the year. I want an array like this

JAN-01, FEB-01,…., DEC-01, JAN-02,…., DEZ-02, JAN-03
miguelna
New php-forum User
New php-forum User
 
Posts: 15
Joined: Wed Sep 04, 2002 12:53 am

Postby Jay » Fri Sep 20, 2002 12:10 pm

That's simple. I won't write the function out for you, but I'll give you the gist of what you need to do!

Now, you know every month has a 1st, so you don't need to use that every time. What you need to do is get the start date (2002-01-01) and increment each month (2002-02-01, etc) until it hits 12! Then you need to start from 1 again, and increment the year! It's simple enough, you should be able to make that!

Once you've got the date in a YYYY-MM-DD format, you can use the date function to display it as whatever you like!
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: thesmahesh and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.