$mybb->settings['dateformat'] NOT working properly.
Niki Offline
Junior Member
**
Posts: 29
Joined: Oct 2016
Post: #1
$mybb->settings['dateformat'] NOT working properly.
I have the Date Formats set up in the configuration as: m-d-Y

I've created a new page to show absent members, however the dateformat is not using the mybb settings format on this page specifically.

Current time now shows relative correct date like: 02-18-2018
This page shows it like: 28-2-2018

What have I done wrong?

PHP Code:
$returndate = $users['returndate'];

(This post was last modified: 02-21-2018 02:40 PM by Niki.)
02-21-2018 02:33 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #2
RE: $mybb->settings['dateformat'] NOT working properly.
returndate is stored as a string in users table.

02-21-2018 10:28 PM
Find all posts by this user Quote this message in a reply
Niki Offline
Junior Member
**
Posts: 29
Joined: Oct 2016
Post: #3
RE: $mybb->settings['dateformat'] NOT working properly.

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$query = $db->query("
		SELECT *
		FROM ".TABLE_PREFIX."users
		WHERE ".TABLE_PREFIX."users.usergroup IN (4,6,14,17)
		ORDER BY username ASC
	");
while($users = $db->fetch_array($query))    {
	if($users['away'] == '1')	{
		$users['username'] = format_name($users['username'], $users['usergroup'], $users['displaygroup']);
		$users['awaydate'] = my_date($mybb->settings['dateformat'], $users['awaydate']);
		$returndate = $users['returndate'];
		$awayreason = $users['awayreason'];
		eval("\$absentmember .= \"".$templates->get("absentmember_entry")."\";");
	}
}


I'm really not sure what that means? Where do I go to fix this issue? :/

02-22-2018 03:49 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: $mybb->settings['dateformat'] NOT working properly.
Which one doesn't work as intended? The returndate as stated in the first post or the awaydate?

(02-22-2018 03:49 AM)Niki Wrote:  I'm really not sure what that means? Where do I go to fix this issue? :/
returndate is saved as a plain text in users table. It is "formatted" as j-n-Y. You can't use $mybb->settings['dateformat'] directly into it. You need to convert it to UNIX Timestamp first.

02-22-2018 05:05 AM
Find all posts by this user Quote this message in a reply
Niki Offline
Junior Member
**
Posts: 29
Joined: Oct 2016
Post: #5
RE: $mybb->settings['dateformat'] NOT working properly.
Returndate did not work as it should, awaydate is just fine.

Where do I go to convert this to UNIX Timestamp?
02-22-2018 08:20 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: $mybb->settings['dateformat'] NOT working properly.
There are several ways to do that, either using mktime (you need to explode the returndate first to get month, day and year), strtotime (since it is already in day-month-year and using dash (-) as a separator, you can use it directly) or by using DateTime::createFromFormat / date_create_from_format (need at least PHP 5.3, you can also use it directly).

02-23-2018 01:04 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: