473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

PHP Date Manipulation

All, first post, very exciting

I have a list of dates that are given in the form of a two dimentional
array.

Ex.

var $timeOfYear = array(
1 =array(
'name' ='begining',
'start' ='1/1',
'end' ='5/31'
),
2 =array(
'name' ='end',
'start' ='6/1',
'end' ='12/31'
),
3 =array(
'name' ='special fun time',
'start' ='3/21',
'end' ='6/20'
)
);

Now, I want to take the current date and find what period it falls
into. Obviously, this is a very simple case and will be more
complicated in practice... Note that some periods overlap, in this
case we fall into the shortest period.

My idea was to sort the array from shortest period to longest, then
iterate until I find a match. I don't really know the best way to do
that in PHP. Thanks in advance!
Mar 5 '08 #1
1 1505
walnutmon wrote:
All, first post, very exciting

I have a list of dates that are given in the form of a two dimentional
array.

Ex.

var $timeOfYear = array(
1 =array(
'name' ='begining',
'start' ='1/1',
'end' ='5/31'
),
2 =array(
'name' ='end',
'start' ='6/1',
'end' ='12/31'
),
3 =array(
'name' ='special fun time',
'start' ='3/21',
'end' ='6/20'
)
);

Now, I want to take the current date and find what period it falls
into. Obviously, this is a very simple case and will be more
complicated in practice... Note that some periods overlap, in this
case we fall into the shortest period.

My idea was to sort the array from shortest period to longest, then
iterate until I find a match. I don't really know the best way to do
that in PHP. Thanks in advance!
Check out usort(). You can define the function that sorts the array to
be whatever you want.

One thought - what do you do if an element spans the end of the year?
Or the end of February (this is a leap year, after all).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Mar 7 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
16
by: jason | last post by:
I'm tearing out my hair here: ACCESS 2000: When I attempt to overwrite a date in my date field with a new user selected valid date eg: 05/23/99 my date field changes to the TIME I updated the...
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
5
by: John Kiernan | last post by:
Hey JavaScript gurus! Here's a weird one: If I check (with an alert) this line: vStrDate2 = vDate.toLocaleString(); I get: Saturday, August 14, 2004 7:57:30 PM (as I should) but this...
26
by: sgershon | last post by:
Hi. I know this is should be a simple question. I know server-side web-programming, and never needed to use client-side scripting... until now :) I have done so far a little number of scripts...
5
by: WindAndWaves | last post by:
Hi Gurus This is a cry for help to all of you. I am looking for some sort of plug-in/active X/code/link to outlook/what have you, which I can add to my MS Access database for my users to...
1
by: Graham Feeley | last post by:
I have a date field named rcdate it is a general date eg: 12/08/2006 3:30:00 PM 12/08/2006 3:00:00 PM I used to update another empty field named rdate with the with using in a update query "...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
2
by: Billy | last post by:
This string is supposed to provide all records from an MDB database that match the courier and date specified in the query. I Response.Write the query and I get a date as 1/27/2007. The date...
3
by: GorseFox | last post by:
Forgive me. I am new to PHP and am a little confused by date manipulation and would appreciate some guidance. I have a string containing a date which has been parsed from and RSS feed. This looks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.