PDA

View Full Version : Format raw birthday.


Seductor
09-07-2012, 09:25 PM
Is there any way to format a birthday in European format?
European Format (e.g., 25-04-98): d-m-y

Now it is in American format:
[birthday] => 03-04-1976
[birthday_search] => 1976-03-04

I want to use it as {vb:raw birthday} in European format.

Could it be possible? Thanks in advance.

--------------- Added 1347110644 at 1347110644 ---------------

I can't do a PHP conversi?n because I want to format $post['birthday'].

kh99
09-08-2012, 04:14 PM
Where do you want to be able to use it? I don't think there's any way to change what's in the database (unless you want to modify some of the vbulletin code), but you might be able to add a field to a SELECT and format it using MySQL functions.

nerbert
09-08-2012, 04:33 PM
Settings > Options > Date and Time Options

kh99
09-08-2012, 06:27 PM
Oh right - that's a good point (if the birthday is already being displayed and you want to change the format). I was thinking of displaying it somewhere where it isn't showing at all. But even if that were true, my idea would still need a plugin so I guess it's not much help.

Seductor
09-09-2012, 11:13 AM
Where do you want to be able to use it? I don't think there's any way to change what's in the database (unless you want to modify some of the vbulletin code), but you might be able to add a field to a SELECT and format it using MySQL functions.

I think I'll take this option, because the birthday is not being displayed and I want to change the output format.

March 04, 1976 it's shown by {vb:raw post.birthday} as: 03-04-1976.

So, I think I'll do a plugin. So, I need to know something:
Is there anything like $vbulletin->userinfo but for posts? Something like $vbulletin->post?

--------------- Added 1347193081 at 1347193081 ---------------

Yes, it is... $post[birthday] ... and I should do... something like...

$arr_birthday = explode('-', $post[birthday]);
$eur_birthday = $arr_birthday[1]."-".$arr_birthday[0]."-".$arr_birhday[2];

And I should register that variable in postbit.

What do you think about it?

Seductor
09-09-2012, 11:29 AM
At least, it works. But I wish I could register it in $post instead of using my own variable. Could I do $post['eur_birthday'] = $eur_birthday, in order to do {vb:raw post.eur_birthday}?

kh99
09-09-2012, 11:33 AM
Yes, that's probably what I would do. You might want to add a check to make sure $post[birthday] is set, and also there is be a $post[showbirthday] value that has the user's privacy selection:

0 = Hide Age and Date of Birth
1 = Display Only Age
2 = Display Age and Full Date of Birth
3 = Display Only Day and Month of Birth

Seductor
09-09-2012, 11:41 AM
(Do you think it could be useful If I release it as a add-on?)

One last question: I've tried to display $post.userfield11, which is a string(19), but nothing is shown.


Array
(
...
[field11] => Bla bla bla
...
}


It is var_dumped okay, but it is not shown in postbit. Why could it be?

kh99
09-09-2012, 11:54 AM
(Do you think it could be useful If I release it as a add-on?)

Well, I don't know that it would be really popular, but there's probably at least a few people out there who would use it.

One last question: I've tried to display $post.userfield11, which is a string(19), but nothing is shown.

Maybe it's just that you've used 'userfield11' instead of just 'field11'?

Seductor
09-09-2012, 12:03 PM
No, it is not:
<div>City: {vb:raw post.field11}</div>

* Seductor seems puzzled.

kh99
09-09-2012, 12:07 PM
Hmm...that is strange. Where are you printing out the value, is that in a postbit plugin (the printout in post#8, I mean)?

Seductor
09-09-2012, 12:58 PM
It is in the postbit_legacy template. But when I vardumped it, it was in the plugin (I don't know any way to do a var_dump or similar within the template).

kh99
09-09-2012, 01:15 PM
I don't know either. As far as I know, if $post['field11'] is set when construct_postbit is called, then using {vb:raw post.field11} in the postbit template should display it.

Scanu
09-09-2012, 03:09 PM
Are you sure you typed something in that field? It's verg strange...

Seductor
09-09-2012, 04:35 PM
@Scanu, I'm sure. Take a look at this. I'm using TMS:
PHPMyAdmin:
https://vborg.vbsupport.ru/external/2012/09/37.png

TMS::
https://vborg.vbsupport.ru/external/2012/09/38.png

Code:
https://vborg.vbsupport.ru/external/2012/09/39.png

And In_array works, because it shows the birthday properly.

Scanu
09-09-2012, 04:59 PM
Does it work if you manually put "{vb:raw post.field11}" in postbit?