Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 07 Sep 2012, 22:25
Seductor Seductor is offline
 
Join Date: May 2011
Format raw birthday.

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 08 Sep 2012 at 13:24 ---------------

I can't do a PHP conversión because I want to format $post['birthday'].
Reply With Quote
  #2  
Old 08 Sep 2012, 17:14
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #3  
Old 08 Sep 2012, 17:33
nerbert nerbert is offline
 
Join Date: May 2008
Settings > Options > Date and Time Options
Reply With Quote
  #4  
Old 08 Sep 2012, 19:27
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #5  
Old 09 Sep 2012, 12:13
Seductor Seductor is offline
 
Join Date: May 2011
Originally Posted by kh99 View Post
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 09 Sep 2012 at 12:18 ---------------

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?
Reply With Quote
  #6  
Old 09 Sep 2012, 12:29
Seductor Seductor is offline
 
Join Date: May 2011
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}?
Reply With Quote
  #7  
Old 09 Sep 2012, 12:33
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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

Last edited by kh99; 09 Sep 2012 at 12:55.
Reply With Quote
  #8  
Old 09 Sep 2012, 12:41
Seductor Seductor is offline
 
Join Date: May 2011
(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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It is var_dumped okay, but it is not shown in postbit. Why could it be?
Reply With Quote
  #9  
Old 09 Sep 2012, 12:54
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by Seductor View Post
(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'?
Reply With Quote
  #10  
Old 09 Sep 2012, 13:03
Seductor Seductor is offline
 
Join Date: May 2011
No, it is not:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

/me seems puzzled.
Reply With Quote
  #11  
Old 09 Sep 2012, 13:07
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Hmm...that is strange. Where are you printing out the value, is that in a postbit plugin (the printout in post#8, I mean)?
Reply With Quote
  #12  
Old 09 Sep 2012, 13:58
Seductor Seductor is offline
 
Join Date: May 2011
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).
Reply With Quote
  #13  
Old 09 Sep 2012, 14:15
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #14  
Old 09 Sep 2012, 16:09
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Are you sure you typed something in that field? It's verg strange...
Reply With Quote
  #15  
Old 09 Sep 2012, 17:35
Seductor Seductor is offline
 
Join Date: May 2011
@Scanu, I'm sure. Take a look at this. I'm using TMS:
PHPMyAdmin:


TMS::


Code:


And In_array works, because it shows the birthday properly.

Last edited by Seductor; 09 Sep 2012 at 17:42.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 14:39.

Layout Options | Width: Wide Color: