Re: [PHP] Firs Day Of Week UNIX

2010-10-20 Thread Richard Quadling
On 19 October 2010 14:59, Don Wieland d...@dwdataconcepts.com wrote:
 Hi gang,

 I need a bailout.

 I have a fields called sys_first_day_of_week and the user can select one
 value which will be from a menu with these options:

 Monday
 Tuesday
 Wednesday
 Thursday
 Friday
 Saturday
 Sunday

 Based on this Preference and TODAYS DATE, I want to calculate the first
 day of the week.

 So if my preference is Monday and Today's date is 10/19/2010, I want to
 return a value of: 1287374400 (which is 10/18/2010)

 if my preference is Wednesday and Today's date is 10/19/2010, I want to
 return a value of: 1286942400 (which is 10/13/2010)

 Appreciate any help.

 Don Wieland
 D W   D a t a   C o n c e p t s
 ~
 d...@dwdataconcepts.com
 Direct Line - (949) 336-4828

 Integrated data solutions to fit your business needs.

 Need assistance in dialing in your FileMaker solution? Check out our
 Developer Support Plan at:
 http://www.dwdataconcepts.com/DevSup.html

 Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or
 higher
 http://www.appointment10.com

 For a quick overview -
 http://www.appointment10.com/Appt10_Promo/Overview.html



?php
echo date('r', strtotime('-1 week', strtotime('next sunday'))); //
Sun, 17 Oct 2010 00:00:00 +0100
echo date('r', strtotime('-1 week', strtotime('next monday'))); //
Mon, 18 Oct 2010 00:00:00 +0100
echo date('r', strtotime('-1 week', strtotime('next tuesday'))); //
Tue, 19 Oct 2010 00:00:00 +0100
echo date('r', strtotime('-1 week', strtotime('next wednesday'))); //
Wed, 20 Oct 2010 00:00:00 +0100
echo date('r', strtotime('-1 week', strtotime('next thursday'))); //
Thu, 14 Oct 2010 00:00:00 +0100
echo date('r', strtotime('-1 week', strtotime('next friday'))); //
Fri, 15 Oct 2010 00:00:00 +0100
echo date('r', strtotime('-1 week', strtotime('next saturday'))); //
Sat, 16 Oct 2010 00:00:00 +0100
?

Take 1 week off the next day that they want. If today is the start of
the week, then today will be returned.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Firs Day Of Week UNIX

2010-10-19 Thread Don Wieland

Hi gang,

I need a bailout.

I have a fields called sys_first_day_of_week and the user can select  
one value which will be from a menu with these options:


Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Based on this Preference and TODAYS DATE, I want to calculate the  
first day of the week.


So if my preference is Monday and Today's date is 10/19/2010, I want  
to return a value of: 1287374400 (which is 10/18/2010)


if my preference is Wednesday and Today's date is 10/19/2010, I want  
to return a value of: 1286942400 (which is 10/13/2010)


Appreciate any help.

Don Wieland
D W   D a t a   C o n c e p t s
~
d...@dwdataconcepts.com
Direct Line - (949) 336-4828

Integrated data solutions to fit your business needs.

Need assistance in dialing in your FileMaker solution? Check out our  
Developer Support Plan at:

http://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro  
9 or higher

http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html



[PHP] Firs Day Of Week UNIX

2010-10-19 Thread Don Wieland

Hi gang,

I need a bailout.

I have a fields called sys_first_day_of_week and the user can select  
one value which will be from a menu with these options:


Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Based on this Preference and TODAYS DATE, I want to calculate the  
first day of the week.


So if my preference is Monday and Today's date is 10/19/2010, I want  
to return a value of: 1287374400 (which is 10/18/2010)


if my preference is Wednesday and Today's date is 10/19/2010, I want  
to return a value of: 1286942400 (which is 10/13/2010)


Appreciate any help.

Don

Re: [PHP] Firs Day Of Week UNIX

2010-10-19 Thread Sebastian Detert

Don Wieland schrieb:

Hi gang,

I need a bailout.

I have a fields called sys_first_day_of_week and the user can select 
one value which will be from a menu with these options:


Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Based on this Preference and TODAYS DATE, I want to calculate the 
first day of the week.


So if my preference is Monday and Today's date is 10/19/2010, I want 
to return a value of: 1287374400 (which is 10/18/2010)


if my preference is Wednesday and Today's date is 10/19/2010, I want 
to return a value of: 1286942400 (which is 10/13/2010)


Appreciate any help.

Don

I'm not sure: You are searching the date of the last given weekdate?

$sys_first_day_of_week: Monday = 1, ..., Saturday = 6, Sunday = 0

Try this one: date seems to be correct, but value is different, maybe 
different time zone?


if ( date('w')  $sys_first_day_of_week ) {
 $value = mktime(0,0,0,date('n'),date('j'),date('Y')) - ( 7 + date('w') 
- $sys_first_day_of_week ) * 24 * 60 * 60;

}
else {
 $value = mktime(0,0,0,date('n'),date('j'),date('Y')) - ( date('w') - 
$sys_first_day_of_week ) * 24 * 60 * 60;

}



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Firs Day Of Week UNIX

2010-10-19 Thread Paul M Foster
On Tue, Oct 19, 2010 at 07:00:55AM -0700, Don Wieland wrote:

 Hi gang,
 
 I need a bailout.
 
 I have a fields called sys_first_day_of_week and the user can select
 one value which will be from a menu with these options:
 
 Monday
 Tuesday
 Wednesday
 Thursday
 Friday
 Saturday
 Sunday
 
 Based on this Preference and TODAYS DATE, I want to calculate the
 first day of the week.
 
 So if my preference is Monday and Today's date is 10/19/2010, I want
 to return a value of: 1287374400 (which is 10/18/2010)
 
 if my preference is Wednesday and Today's date is 10/19/2010, I want
 to return a value of: 1286942400 (which is 10/13/2010)
 
 Appreciate any help.

I would strongly suggest you use a date class which uses julian days
internally to represent dates. This makes date calculations vastly more
simple and accurate than using seconds to do the calculation. I have a
date class I'll send you, if you like.

Just get today's date, and today's day of the week. Then just add or
subtract days to get the other dates needed. In fact, the date class I
mentioned has two functions, begwk() and endwk() which allows you to
return the beginning or ending of the week, based on today's date and a
user-configurable end-of-week day.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Firs Day Of Week UNIX

2010-10-19 Thread Tommy Pham
 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, October 19, 2010 7:37 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Firs Day Of Week UNIX
 
 On Tue, Oct 19, 2010 at 07:00:55AM -0700, Don Wieland wrote:
 
  Hi gang,
 
  I need a bailout.
 
  I have a fields called sys_first_day_of_week and the user can select
  one value which will be from a menu with these options:
 
  Monday
  Tuesday
  Wednesday
  Thursday
  Friday
  Saturday
  Sunday
 
  Based on this Preference and TODAYS DATE, I want to calculate the
  first day of the week.
 
  So if my preference is Monday and Today's date is 10/19/2010, I want
  to return a value of: 1287374400 (which is 10/18/2010)
 
  if my preference is Wednesday and Today's date is 10/19/2010, I want
  to return a value of: 1286942400 (which is 10/13/2010)
 
  Appreciate any help.
 
 I would strongly suggest you use a date class which uses julian days
 internally to represent dates. This makes date calculations vastly more
 simple and accurate than using seconds to do the calculation. I have a
date
 class I'll send you, if you like.
 
 Just get today's date, and today's day of the week. Then just add or
subtract
 days to get the other dates needed. In fact, the date class I mentioned
has
 two functions, begwk() and endwk() which allows you to return the
 beginning or ending of the week, based on today's date and a user-
 configurable end-of-week day.
 
 Paul
 
 --
 Paul M. Foster
 

Date class with methods begwk()  endwk()?  Is that from PEAR/PECL?  I don't
see it in the manual.  I do see getDate() [1];

?php
$today = getdate();
print_r($today);
?
Array
(
[seconds] = 40
[minutes] = 58
[hours]   = 21
[mday]= 17
[wday]= 2
[mon] = 6
[year]= 2003
[yday]= 167
[weekday] = Tuesday
[month]   = June
[0]   = 1055901520
)

This would get you going.

Regards,
Tommy

[1] http://us.php.net/manual/en/function.getdate.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Firs Day Of Week UNIX

2010-10-19 Thread Paul M Foster
On Tue, Oct 19, 2010 at 08:14:47AM -0700, Tommy Pham wrote:

  -Original Message-
  From: Paul M Foster [mailto:pa...@quillandmouse.com]
  Sent: Tuesday, October 19, 2010 7:37 AM
  To: php-general@lists.php.net
  Subject: Re: [PHP] Firs Day Of Week UNIX
 
  On Tue, Oct 19, 2010 at 07:00:55AM -0700, Don Wieland wrote:
 
   Hi gang,
  
   I need a bailout.
  
   I have a fields called sys_first_day_of_week and the user can select
   one value which will be from a menu with these options:
  
   Monday
   Tuesday
   Wednesday
   Thursday
   Friday
   Saturday
   Sunday
  
   Based on this Preference and TODAYS DATE, I want to calculate the
   first day of the week.
  
   So if my preference is Monday and Today's date is 10/19/2010, I want
   to return a value of: 1287374400 (which is 10/18/2010)
  
   if my preference is Wednesday and Today's date is 10/19/2010, I want
   to return a value of: 1286942400 (which is 10/13/2010)
  
   Appreciate any help.
 
  I would strongly suggest you use a date class which uses julian days
  internally to represent dates. This makes date calculations vastly more
  simple and accurate than using seconds to do the calculation. I have a
 date
  class I'll send you, if you like.
 
  Just get today's date, and today's day of the week. Then just add or
 subtract
  days to get the other dates needed. In fact, the date class I mentioned
 has
  two functions, begwk() and endwk() which allows you to return the
  beginning or ending of the week, based on today's date and a user-
  configurable end-of-week day.
 
  Paul
 
  --
  Paul M. Foster
 
 
 Date class with methods begwk()  endwk()?  Is that from PEAR/PECL?  I don't
 see it in the manual.  I do see getDate() [1];

No, it's from PMF. (I wrote it.) ;-}

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php