# Calculate timestamp 00:00:00 last sunday

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
Hi every one,

Is there a way to calculate the timestamp of 00:00:00 last Sunday. For
me, this is the begin of the current week..
Or, how old is this week, in seconds

Any ideas?

Regards,

fré

## Re: Calculate timestamp 00:00:00 last sunday

<?php echo date('Y-m-d H:i:s', strtotime('last sunday 00:00:00')); ?>

prints: 2006-07-09 00:00:00

How old this week is in seconds: mktime() - strtotime('last sunday
00:00:00');

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

## Re: Calculate timestamp 00:00:00 last sunday

thanks, that did it!

## Re: Calculate timestamp 00:00:00 last sunday

griemer wrote:

But the week starts 00:00:00 on Monday, or that dependant on locale?

## Re: Calculate timestamp 00:00:00 last sunday

Robin wrote:

Ha, so it's not only a discussion in the Netherlands :-).

As far as I know, sunday has always been the first day of the week. What
gets people confused is the term 'weekend' for week-transition, and a lot of
people incorrectly get the Bible in it, saying:"On the seventh day he
rested, so that should be sunday." While the seventh day is indeed saturday,
http://en.wikipedia.org/wiki/Sunday )

The start of a 'working" week is indeed monday, but thank god it stops at
friday :-).

Grtz,
--
Rik Wasmus

## Re: Calculate timestamp 00:00:00 last sunday

Maybe in Netherlands. Then there are those who concider Monday the first day
of the week, like us Finnish people or the ISO 8601 standard. There's no
point in arguing which is right, let's just agree to disagree and let
everyone have their own way of counting days. Pounds, miles, kilograms and
meters, whatever.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

## Re: Calculate timestamp 00:00:00 last sunday

Kimmo Laine wrote:

Yep, I guess it depends on where you are.  For instance, here in the
U.S., calendars display Sunday through Saturday.  Everyone considers
Sunday to be the first day of the week.  Monday is generally considered
the first day of the work week.

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

## Re: Calculate timestamp 00:00:00 last sunday

Yes, it's locale-dependent, as per the other replies. In the UK, the week is
(generally) considered to start on Monday. There's various religious, practical
and linguistic differences that mean it's either Sunday or Monday depending on
which one you or your country picks.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

## Re: Calculate timestamp 00:00:00 last sunday

mmmm,  i'm a little confused now.
Not about wich day is the first day of the week, but on how 'last
sunday' is calculated.

Obviously, when you're talking about 'last sunday'  on a sunday, you're
talking about the sunday  which was a week ago.

BUT........

I think i have to say it a little different:  How do i calculate the
total amount of seconds that have past since the last transition from
saturday to sunday.

So, every day of the week this is 'last sunday' , exept on sundays,
then its 'today

So the amount will never by more than 3600 * 24 * 7  seconds.

I also like to know the date of that sunday

Regards,
Fré

## Re: Calculate timestamp 00:00:00 last sunday

griemer wrote:

I'm not fond of strototime(), so let't do it by hand:

function last_sunday(\$date = false){
if(\$date===false) \$date = time();
\$last_sunday =
mktime(0,0,0,date('n',\$date),date('j',\$date),date('Y',\$date)) - (24 * 60 *
60 * date('w',\$date));
return \$date - \$last_sunday; //number of seconds since last transition
}

Will return the number of seconds since last sunday 00:00:00, calculated
from date, or from time() if not givem.

Grtz,
--
Rik Wasmus