473,407 Members | 2,326 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,407 software developers and data experts.

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 11227
"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*60*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.net | 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*60*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
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...
5
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 ...
1
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...
1
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...
3
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...
3
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...
9
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...
6
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,...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.