473,513 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP/MySQL to ignore part of a date.

8 New Member
I have this mod for my forum and it calls the birthdate from the database. I would like to have it not see the year. What is happening if a person puts a year in the box in their profile it makes it Dec 31st because that year is already over. There is no way to remove that box from the code according to the forum tech people. I've added the two pieces that refer to date. It already is written where it only shows the month and day in the display. Thank you to anyone that can help.


[PHP]$birthdays = get_birthdays();
if(!$birthdays) {
$text = 'No birthdays yet';
} else {
$num = count($birthdays);

$i = 1;

foreach($birthdays as $b) {
$date = explode("-", $b["user_birthday"]);
$user = get_user($b["user_id"]);
$user_menus[] = create_user_popup($user);
if($date[2] == date('j')) {
$text.= "<img src='" . BASE_DIR . "/birthday.gif' title=\"User's birthday today!\"/>";
$dateprint = '<span style=\'color:red\'><strong>TODAY!</strong></span>';
} else {
$dateprint = date('F jS', mktime(0, 0, 0, $date[1], $date[2], $date[0]));
}
$text .= user_link_code($b["user_id"], $b["user_name"]);
$text .= " (" . $dateprint . ")";
if($num > $i) {
$text .= ', ';
}
$i++;
}

} [/PHP]


[PHP]/**** BEGIN BIRTHDAYS TODAY ****/
function get_birthdays() {
$result = db_query("SELECT user_id, user_name, user_birthday FROM wowbb_users
WHERE DAYOFMONTH(user_birthday) >= DAYOFMONTH(NOW()) AND MONTH(user_birthday) = MONTH(CURRENT_DATE) AND DAYOFMONTH(user_birthday) < DAYOFMONTH(CURRENT_DATE)+7
ORDER BY DAYOFMONTH(user_birthday) ASC;");
while($row = db_fetch_row($result)) {
$birthdays[] = $row;
}
return $birthdays;
}

/**** END BIRTHDAYS TODAY ****/[/PHP]
Jun 11 '07 #1
3 1738
nomad
664 Recognized Expert Contributor
never mind I was doing this is mysql

nomad
Jun 11 '07 #2
pbmods
5,821 Recognized Expert Expert
Removed 'pretty please' from thread title.
Jun 12 '07 #3
nomad
664 Recognized Expert Contributor
Hi Nancy:
I was thinking about your problem. Not sure if this will work
Could you create another class Called FormatDate.
which would have something like this.

<?php
return "02d/%02d<br>";
?>

This will get rid of the year.

nomad

or how about using the functon sprintf(),
Jun 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4409
by: Neil | last post by:
Hi, I hope this question isn't too far off topic....I'm almost at my wits end trying to figure this out. I have a Mysql database and I wish to automate the backup of the database because I...
0
3510
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary...
4
2412
by: jy2003 | last post by:
I have read a book, which suggests we should change OR to UNION for better performance, but currently I have too many OR clauses(I have a query with 100 ORs) and it does not sound good to have 100...
9
6749
by: expect | last post by:
Hello, Trying to get this MySql create table command to work, no luck. create sequence serial; CREATE TABLE outbound ( source char(100) default '', destination char(100) default '', sport...
13
2289
by: Jim Hubbard | last post by:
I have a client that desires a new application for use at several stores in different cities. He wants "real time" access to all store data and the ability to continue to run locally even if the...
29
2871
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
5
1696
by: atyndall | last post by:
OK, Well I've got this script and I'd like to implement this function into it where a function retrieves a specified amount of data from a specific mysql database, rearranges a part of it, and...
6
38453
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
6
3927
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
0
7257
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
7379
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,...
1
7098
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
7521
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
5682
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,...
1
5084
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...
0
4745
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...
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.