View Full Version : Formatting birthdate question
Boofo
07-11-2004, 06:34 PM
Can someone please tell me how to make this:
01-31-54into this:
January 31, 1954with the following line?
$birthdate=$bbuserinfo['birthday'];
I tried doing the vbdate($vboptions['dateformat'] string, but it gives me Dec, 31st, 1969 for anything before 1970. I know this is fixed in vB3, but for some reason it isn't working for that line. I am using this in a file for realchat to pass paranmeters to the chat program. This is the only thing I have that is not working the way I want it to.
Thank you in advance. ;)
Modin
07-11-2004, 11:30 PM
Try this Boofo... :)
$birthdate_parts = explode("-", $bbuserinfo['birthday']);
$birthday = date("F j, Y", mktime(0, 0, 0, $birthdate_parts[0], $birthdate_parts[1], $birthdate_parts[3]));
Dark_Wizard
07-11-2004, 11:31 PM
Try this:
$bday = explode('-', $bbuserinfo['birthday']);
if (date('Y') > $bday[2] AND $bday[2] > 1901 AND $bday[2] != '0000')
{
require_once('./includes/functions_misc.php');
$vboptions['calformat1'] = mktimefix($vboptions['calformat1'], $bday[2]);
$bbuserinfo['birthday'] = vbdate($vboptions['calformat1'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
}
else
{
$bbuserinfo['birthday'] = vbdate($vboptions['calformat2'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
}
$birthdate = $bbuserinfo['birthday'];
Dark_Wizard
07-11-2004, 11:33 PM
LOL...that had to be a second off...didn't know you were looking at it as well
Modin
07-11-2004, 11:51 PM
lol :)
mktimefix eh... will have to look at that function ;)
Boofo
07-12-2004, 12:38 PM
Try this:
$bday = explode('-', $bbuserinfo['birthday']);
if (date('Y') > $bday[2] AND $bday[2] > 1901 AND $bday[2] != '0000')
{
require_once('./includes/functions_misc.php');
$vboptions['calformat1'] = mktimefix($vboptions['calformat1'], $bday[2]);
$bbuserinfo['birthday'] = vbdate($vboptions['calformat1'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
}
else
{
$bbuserinfo['birthday'] = vbdate($vboptions['calformat2'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
}
$birthdate = $bbuserinfo['birthday'];
That worked like a charm, thank you, sir. ;)
One last thing, if I want to strip the DAY out of that string, how could I do that? I use
l, FjS, Y
for the birthdays on my board, but in this program I only want
F j, Y
Can this be done?
Boofo
07-12-2004, 12:40 PM
Try this Boofo... :)
$birthdate_parts = explode("-", $bbuserinfo['birthday']);
$birthday = date("F j, Y", mktime(0, 0, 0, $birthdate_parts[0], $birthdate_parts[1], $birthdate_parts[3]));
Thank you, sir. Your code worked great for the day but it showed 2000 for my birth year, which is just a little off. But you were a heck of a lot closer than I have been able to get. ;)
Dark_Wizard
07-12-2004, 06:05 PM
That worked like a charm, thank you, sir. ;)
One last thing, if I want to strip the DAY out of that string, how could I do that? I use
l, FjS, Y
for the birthdays on my board, but in this program I only want
F j, Y
Can this be done?
Change this:
$bbuserinfo['birthday'] = vbdate($vboptions['calformat1'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
to this:
$bbuserinfo['birthday'] = date('F j, Y', mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
Boofo
07-12-2004, 07:13 PM
Change this:
$bbuserinfo['birthday'] = vbdate($vboptions['calformat1'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
to this:
$bbuserinfo['birthday'] = date('F j, Y', mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
I get this error with the change:
Wrong parameter count for date()
Dark_Wizard
07-12-2004, 09:00 PM
I get this error with the change:
Oops...change it to this:
$bbuserinfo['birthday'] = date("F j, Y", mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
Boofo
07-12-2004, 09:41 PM
Oops...change it to this:
$bbuserinfo['birthday'] = date("F j, Y", mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
I tried that one after the first one didn't work. I get the same error with this, too. ;)
Dark_Wizard
07-13-2004, 10:46 PM
Use this:
$format1 = 'F j, Y';
$format2 = 'F j';
$bday = explode('-', $bbuserinfo['birthday']);
if (date('Y') > $bday[2] AND $bday[2] > 1901 AND $bday[2] != '0000')
{
require_once('./includes/functions_misc.php');
$format1 = mktimefix($format1, $bday[2]);
$bbuserinfo['birthday'] = vbdate($format1, mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
}
else
{
$bbuserinfo['birthday'] = vbdate($format2, mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
}
$birthdate = $bbuserinfo['birthday'];
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.