By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Calculate timestamp 00:00:00 last sunday

P: n/a
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é

Jul 13 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
"griemer" <gr*****@chello.nlwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
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?

<?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
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Jul 13 '06 #2

P: n/a
thanks, that did it!

Jul 13 '06 #3

P: n/a
griemer wrote:
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é
But the week starts 00:00:00 on Monday, or that dependant on locale?
Jul 13 '06 #4

P: n/a
Rik
Robin wrote:
griemer wrote:
> 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é

But the week starts 00:00:00 on Monday, or that dependant on locale?
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,
that's why the jews have Sabbath. (See also
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
Jul 13 '06 #5

P: n/a
"Rik" <lu************@hotmail.comwrote in message
news:5f***************************@news2.tudelft.n l...
Robin wrote:
>griemer wrote:
>> 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é

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

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.
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
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Jul 13 '06 #6

P: n/a
Kimmo Laine wrote:
"Rik" <lu************@hotmail.comwrote in message
news:5f***************************@news2.tudelft.n l...
>>Robin wrote:
>>>griemer wrote:

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é
But the week starts 00:00:00 on Monday, or that dependant on locale?

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.


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.
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.
js*******@attglobal.net
==================
Jul 13 '06 #7

P: n/a
On Thu, 13 Jul 2006 09:37:52 +0100, Robin <an**@somewhere.comwrote:
>But the week starts 00:00:00 on Monday, or that dependant on locale?
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 :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 13 '06 #8

P: n/a
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é

Jul 17 '06 #9

P: n/a
Rik
griemer wrote:
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
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
Jul 17 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.