View Full Version : Current date in templates?
Mattwhf
06-03-2017, 11:32 AM
Hello,
Is there a variable to get current date in vb 4 templates?
for example, I want to show this
June 03, 2017
Thanks
grey_goose
06-06-2017, 11:13 AM
I've done something similar, by creating a plugin.
Hook Location: global_bootstrap_init_start
Title: Current Timestamp
$timeplugin = time();
vB_Template::preRegister('forumhome_lastpostby',ar ray('timeplugin' => $timeplugin));
vB_Template::preRegister('threadbit',array('timepl ugin' => $timeplugin));
vB_Template::preRegister('USERCP_SHELL',array('tim eplugin' => $timeplugin));
You have to register the variable in each template you want to call {vb:raw timeplugin} in. I wanted a UNIX timestamp, but you can either use {vb:date timestamp[, format]} or format it in the plugin with date_format. You can also call it anything you want -- I used "timeplugin" to remind myself of where I was getting the variable from down the road and to avoid any potential conflicts with 'timenow'.
There might be a better way to go about this, but since no one else answered...
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.