Days of running week
Anyone have tips for following function:
I need to display running week days in numbers to seperate fields. I.E.
Week 23 ->
Table 1 -> 21.6.
Table 2 -> 22.6.
Table 3 -> 23.6.
Table 4 -> 24.6.
Table 5 -> 25.6.
And they shouldn't change beaforee week changes.
Another problem which may occur, when month changes during the week.. So got any solutions for this, dear talkphp members?
You could use the date() function to either display the current week number, or get the week number from a string:
Edit: I misunderstood your question. I will try to think out a new solution.
Yes getting the week number isn't the problem as you noticed little later.
The problem is to get numbers of the week.
Lets say I have string $week and it contains current week number and days in array i.e.
week -> 23
sun -> 21
mon -> 22
tue -> 23
wed -> 24
thu -> 25
fri -> 26
sat -> 27
that would be the goal of the function! :-)
There are a number of ways to gather a series of dates. Here are three different code snippets which all produce the same array (see below the code) but are written using different tools.
Note on "sunday last week"
All of the snippets use a string to determine the Sunday at the beginning of this week which may be confusing! If today is Sunday, the string will mean today and not "last Sunday" as you might first assume. This has to do with how strtotime (and the underlying C function get_date) parses such strings. Using Sunday June 28th as an example, "Sunday" means the next Sunday from now (ie, July 5th) and "last week" means take away a week from that Sunday (ie, June 28th).
Onto the snippets. Note that the first two have been formatted to behave more like the third and may not be how one would normally approach this with basic loops and date functions.
They all (should) print the same array:
Works flawless! Thank you Salathe for your help!
I hope this topic helped someone other also!
I will add also the day higlighter but that is too simple to ask :)
|All times are GMT. The time now is 07:44 AM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0