MyBB Community Forums

Full Version: MyBB Time & date function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I've been messing around with the time/date function of mybb, but I can't get it to work..

How to make it so, that when a form is submitted, it uses the time the form is submitted and format it into the MyBB time/date format..

For example, the form has been submitted on 28-10-2012 on 15:00 hour. How to use the my_date function to format it into a MyBB time AND date?

And how to retrieve it properly?

Thanks in advance!

Tankey
You will need to use something like this:

$date = my_date($mybb->settings['dateformat'],$function['dateline']);

$function['dateline'] would be something like when you first query a table, lets say a table named example:

$query = ("SELECT dateline from ".TABLE_PREFIX."example");

Then you fetch it as an array:

while($function = fetch_array($query))
{

//the date part now comes here...

}
Yes, but how to use the current time and store that into the MySQL database? What is the function for that?
TIME_NOW(); or time(); .
Easiest way would be to use the TIME_NOW constant:

$db->insert_query('sometable', array('timestamp' => (int) TIME_NOW));
Inserting into db can be done in this way:

$add = array("dateline" => time(),);

$db->insert_query("table_name",$add);
Yep fixed!

Thanks Craz4Cs & Euantor!