473,554 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get date based on weekday?

Hello,

I have this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun created as links. What I would like to
do is to associate days with its current week dates, for example:

Mon (05.01.2004); Tue (06.01.2004); and so on.

TNX

Jul 17 '05 #1
6 11239
"dr. zoidberg" <so*****@14.u7. da.ru> wrote in message news:<G7******* **********@ns45 .bih.net.ba>...
Hello,

I have this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun created as links. What I would like to
do is to associate days with its current week dates, for example:

Mon (05.01.2004); Tue (06.01.2004); and so on.

TNX


I'm not quite sure what you're trying to accomplish, but you could
always use the date() function.
Jul 17 '05 #2
mjacob wrote:
"dr. zoidberg" <so*****@14.u7. da.ru>
Hello,

I have this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun created as links. What I would like to
do is to associate days with its current week dates, for example:

Mon (05.01.2004); Tue (06.01.2004); and so on.

TNX

I'm not quite sure what you're trying to accomplish, but you could
always use the date() function.


I'm trying do display weekdays with dates, monday to sunday, but only
for current week, something like small calendar.

Jul 17 '05 #3
dr. zoidberg wrote:
I'm trying do display weekdays with dates, monday to sunday, but only
for current week, something like small calendar.


<?php
$wd_arr = array('Mo ', 'Tu ', 'We ', 'Th ', 'Fr ', 'Sa ', 'Su ');
$monday = mktime(0, 0, 0, // hour, minute, second
(int)date('m'), // month
(int)date('d')+ (1-(int)date('w')) , // day (can be negative!)
(int)date('Y')) ; // year

for ($n=0; $n<7; $n++) {
echo $wd_arr[$n], date('Y-m-d', $monday+$n*60*6 0*24), "<br/>\n";
}
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #4
dr. zoidberg schrieb:
mjacob wrote:
"dr. zoidberg" <so*****@14.u7. da.ru>
Hello,

I have this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun created as links. What I would like to
do is to associate days with its current week dates, for example:

Mon (05.01.2004); Tue (06.01.2004); and so on.

TNX


I'm not quite sure what you're trying to accomplish, but you could
always use the date() function.

I'm trying do display weekdays with dates, monday to sunday, but only
for current week, something like small calendar.


Hi mjacob,

i hope this code snippet will help you. I just wrote it down in this
mail, maybe some things do not work instantly but it should at least
show you the way:
// CODE START
switch($weekday ) // $weekday should contain "Sun" or "Mon" and so on
{
case "Sun":
$weekdaynr = 0; // assign a nr representing the weekday
break;
case "Mon":
$weekdaynr = 1;
break;

// ... and so on ...

}

$todaynr = date("w"); // assign the today weekday
$day_diff = $todaynr - $weekdaynr; // get the difference in days
$sec_diff = $daydiff * 24 * 60 * 60; // get the difference in seconds
$target_date = mktime() - $sec_diff; // actual timestamp - difference
echo date ("D (d.M.Y)", $target_date); // output newly formatted date
// CODE END

you can also use strftime() for more format options
Have a nice day,
Chris
Jul 17 '05 #5
On Wed, 07 Jan 2004 16:16:35 +0100, dr. zoidberg wrote:
I'm trying do display weekdays with dates, monday to sunday, but only for
current week, something like small calendar.


DZ..

Check out <http://www.phpbuilder. com/> and do a quick search / hunt for a
calendar app / code on there. One does exist.

Pre-warning... the code doesn't work 100% as it's entered on the site.. I
tried to use it a while back but broke horrible, however, it does have the
data / "formula" for displaying dates relative to days (including "empty
ones".. ie: it knows the start day of the month and the end day for
example) and might help you on your way to what you're aiming for =)
HTH.

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
Programming, Web design, development & hosting.

Jul 17 '05 #6
Pedro Graca wrote:
dr. zoidberg wrote:
I'm trying do display weekdays with dates, monday to sunday, but only
for current week, something like small calendar.

<?php
$wd_arr = array('Mo ', 'Tu ', 'We ', 'Th ', 'Fr ', 'Sa ', 'Su ');
$monday = mktime(0, 0, 0, // hour, minute, second
(int)date('m'), // month
(int)date('d')+ (1-(int)date('w')) , // day (can be negative!)
(int)date('Y')) ; // year

for ($n=0; $n<7; $n++) {
echo $wd_arr[$n], date('Y-m-d', $monday+$n*60*6 0*24), "<br/>\n";
}
?>


Great script.

Few adjustment and I created what I want. TNX
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
14876
by: BlackFireNova | last post by:
I need to write a report in which one part shows a count of how many total records fall within the working days (Monday - Friday) inside of a (prompted) given date range, in a particular geographical region. I have written a query which prompts the user for the start and end dates. It also filters for entries which pertain to the particular...
5
2377
by: Alicia | last post by:
Yes, but will that skip a week and group by the date for me? I basically wanted something that would do a count of the dates, then group them by their week name.. BEFORE: Resource Date Total number of times that date Appeared (Count) 4/3/03 4 4/4/03 2 (note 4/4/03 showed up twice)
1
2800
by: Liz Malcolm | last post by:
Hello and TIA. I have a DE form with an option group that if daily is selected todays date is used for start and end date, if weekly is selected Monday - Friday is used. I am trying to add a manual date selection to clear the start and end date to allow the end user input other days. I have taken into account our financial 1st and last day...
1
2275
by: rock72 | last post by:
I am developing a application using this fields as required by the company. 1. Date Login 2. Time IN 3. Time OUT My question is how to produce the number of days with 1 entry of Date is the entry ?
3
6930
by: haydn_llewellyn | last post by:
Hi, My company runs on a fiscal calendar that starts on the first monday in July, and is based on a 13 week quarter (4 weeks, 4 weeks, 5 weeks). What I need, is a way of relating Date() to the actual fiscal month (e.g. today is 01/07/05, and is the last day in June in our fiscal calendar). I tried many methods, and had hoped that...
3
1510
by: Jon | last post by:
I have a form that is to be used to populate a table (tblBookings) of future Bookings for a chosen weekday - that is selected by a choice of Checkbox's (so they can have one or more days). The user also chooses what year, the dates will be every chosen weekday for that year, (from 1/1 if not this year, from today if this year). I need to...
9
3662
by: AideenWolf | last post by:
Windows XP - Access 2003 I've been researching this for about 3 weeks now and I'm no closer then when I started so any help you all give me will save my hair. I'm VERY new and learning as I go so bare with me. What I want to do is generate a new record for each date an event is held on. The events are reoccuring events. Daily, weekly, etc. ...
6
14332
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future, excluding holidays and weekends.' I didn't want to build a table of holidays that would have to be continuously updated, so I searched high and low...
3
4482
by: Bob Sanderson | last post by:
I have a PHP web page which uses a HTML form. I would like to enter dates into the date fields using a JavaScript calendar, similar to the way phpMyAdmin does. Can anyone recommend a JavaScript that will do this? Also, how can I add a button to a form to enter a NULL. Thanks in advance.
0
7506
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7782
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8018
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7541
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6123
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5423
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5142
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1114
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
823
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.