Question

When Joomla first sprung up and I moved over from Mambo I remember finding a component called Community Builder (CB) that extends the user-based interface behind Joomla.

I remember a small module I found in CB that displayed a couple of useful details about users that I want to be able to extract from my current project. These details included:

  • Total users registered
  • Total users registered per day
  • Total users registered per week
  • Total users registered per month
  • Latest user registered
  • Total visitors to the site

My question is how to recreate something very similar. I've been trying to construct an SQL statement that can manipulate the user table results and compare them to a set criteria eg. find all user's with a 'registerDate' variable within the last week.

The problem that has me lost is how to manipulate and compare a date string that resembles '2008-08-05 07:41:40'

Was it helpful?

Solution

The problem that has me lost is how to manipulate and compare a date string that resembles '2008-08-05 07:41:40'

You can have MySQL turn this into a UNIX timestamp, or you can run it through strtotime.

MySQL:

SELECT UNIX_TIMESTAMP(datetime_field) FROM table

strtotime:

$timestamp = strtotime('2008-08-05 07:41:40');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top