473,889 Members | 1,840 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($birthday s);

$i = 1;

foreach($birthd ays as $b) {
$date = explode("-", $b["user_birth day"]);
$user = get_user($b["user_id"]);
$user_menus[] = create_user_pop up($user);
if($date[2] == date('j')) {
$text.= "<img src='" . BASE_DIR . "/birthday.gif' title=\"User's birthday today!\"/>";
$dateprint = '<span style=\'color:r ed\'><strong>TO DAY!</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("SELEC T user_id, user_name, user_birthday FROM wowbb_users
WHERE DAYOFMONTH(user _birthday) >= DAYOFMONTH(NOW( )) AND MONTH(user_birt hday) = MONTH(CURRENT_D ATE) AND DAYOFMONTH(user _birthday) < DAYOFMONTH(CURR ENT_DATE)+7
ORDER BY DAYOFMONTH(user _birthday) ASC;");
while($row = db_fetch_row($r esult)) {
$birthdays[] = $row;
}
return $birthdays;
}

/**** END BIRTHDAYS TODAY ****/[/PHP]
Jun 11 '07 #1
3 1754
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
4430
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 don't wish to rely on the web host doing so. I am using the "dbsender.php" script, which is written for this exact purpose (available at hotscripts.com). If I execute the script via my browser, the database is emailed to me in a 'gzip' format, which...
0
3545
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 form for a number of platforms from our download pages at http://www.mysql.com/downloads/ and mirror sites.
4
2431
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 UNION. Any suggestion? Will it help if I create an index for (SetID, PID)? SELECT FileID, PID FROM File WHERE SetID = 4 AND (PID = \path\subpath\morepath\0107.html OR PID = \path\subpath\morepath\0101.html OR
9
6771
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 int4 default 0 NOT NULL,
13
2322
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 internet connection goes down. It occurs to me that a local MySQL instance should definitely be in each store to continue work if the net is down for any reason. But, what is the best way to synchronize/share data among all of the stores? ...
29
2916
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
1712
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 outputs the result to another specified varible. this is what i've got so far (please ignore the long-winded variables, they are just for explanations): function RearrangeDate ($input-data/time, $the-way-it-should-be-arranged-e.g.-D/m/y-(not...
6
38547
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 through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
6
3948
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
9966
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11199
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10791
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10442
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9610
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5830
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4647
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 we have to send another system
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3256
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.