vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Format raw birthday. (https://vborg.vbsupport.ru/showthread.php?t=287585)

Seductor 09-07-2012 09:25 PM

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 [DATE]1347110644[/DATE] at [TIME]1347110644[/TIME] ---------------

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

Quote:

Originally Posted by kh99 (Post 2363727)
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 [DATE]1347193081[/DATE] at [TIME]1347193081[/TIME] ---------------

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.

Code:

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

Quote:

Originally Posted by Seductor (Post 2363979)
(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.

Quote:

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:
Code:

  <div>City: {vb:raw post.field11}</div>
[high]* Seductor seems puzzled.[/high]


All times are GMT. The time now is 03:41 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01052 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete