473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Calculate timestamp 00:00:00 last sunday

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
9 3220
"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
thanks, that did it!

Jul 13 '06 #3
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
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
"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: CrystalDBA | last post by:
I am using SQL Server 2000. I need to query my database for all the contracts that came in during a certain time frame (user is prompted for reportingperiodid). Table - Periods Fields -...
1
by: bin_P19 P | last post by:
the code i have got is as follows and now im stuck <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping...
5
by: SimonC | last post by:
Help needed for a Javascript beginner. As above in the subject... i need a javascript to run this, but not in the form of a web-page. I want to calculate it between 2 fields in a database that...
6
by: Jeff Boes | last post by:
(asked last week on .questions, no response) Can anyone explain why this happens? (under 7.4.1) select '2004-05-27 09:00:00.500001-04' :: timestamp(0) ; timestamp ---------------------...
7
by: JJ | last post by:
How do I set one field to have the updated timestamp, and another to have the created timestamp? I want to do this directly from code generated from DB Designer if possible?! JJ
32
by: barkarlo | last post by:
In my table date/time field (starttime,endtime) include both date and time. How can I calculate worktime in query for each employee who works sundays? for an example: sometimes starttime and...
5
Plater
by: Plater | last post by:
So I have been working with the SNTP protocol (RFC4330) And it is saying that the timestamp format of 64bits is: . 1 2 3 0 1...
7
by: Damir | last post by:
I have a situation on a DB server where the "current timestamp" command shows the actual system time offset by one hour, which has never been noticed before?!? The DB2 is V9.1 (FP03), running on...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.