hi,
i need to list the production of a factory for a certain week, for this the user enters a date, and, from this date, i have to know the production for the week in which that day is.. for instance day 5 is a tuesday, so after the user entered 05-02-2008, i have to find out what day is sunday (before) and saturday (after) so i can list in a sql query between.
i thought to first get to know the week number by using: $week=date('W',strtotime($day));
but this day is passed as dd-mm-yyyy, and php only is accepting yyyy-mm-dd, or it returns nonsense weeks.
can i put it the way i want? how?
this is my problem but, if you already did something like this do you have any suggestion for the "whole" problem?
thanks
can't get week of year from date in dd-mm-yyyy format
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: can't get week of year from date in dd-mm-yyyy format
strtotime only accepts specific formats, so if it doesn't support dd-mm-yyyy you'll have to parse it yourself. The easiest way would be to rewrite it into a form strtotime does support, like:
Code: Select all
list($d, $m, $y) = explode('-', $date);
$week=date('W',strtotime("$y-$m-$d"));