Forums

Dates again

daffy 17 Mar, 2009
Hi All,
What a pain calendar dates are ! We have Mysql formats, PHP formats, Javascript formats...a pity they could not agree, worse than the EU.
I am trying to put a string date on an email using chronoforms...well that is what it does...so fine.
Then because I want to do MySQl things with it I want to put it into MySql in a Mysql DATE field, then I want to echo it into my Article including the weekday name, because many users don't pay enough attention and say later 'Oh I thought it was a Friday!'

So I have scanned this forum and like Bob's PHP method of exploding the string and reassembling it in Mysql order.
But Max advocates using Joomla functions like JReqest::setVar(....GetVar( ...));
Bobs is easier to follow but is it slower ?? Are the Joomla functions compiled rather than interpreted ?
If I put (bobs method) into the space 'after submit email' will it get done for insertion into the database ?

Because I have mixed table prefixes in my tables Joomla functions often do not work, which is a nuisance. Why have a prefix if you cannot change it ?? All my personal tables have a different prefix from the Joomla ones, so pure PHP stuff is thus easier to write and use than Joomla stuff.

Any Comments, Help, or Sympathy Welcomed http://www.chronoengine.com/forums/posting.php?mode=post&f=2#
--
Dave
GreyHead 17 Mar, 2009
Hi Dave,

Yes, dates are a pain in the proverbial. I tend to keep a couple of functions up my sleeve and pull them out when needed, but there are many ways of dealing with this. There probably are some slight differences in performance speed but unless you have a great many dates to process you probably aren't going to notice the difference.

And PHP is an interpreted language so there isn's much to be gained there either.

Because I have mixed table prefixes in my tables Joomla functions often do not work, which is a nuisance. Why have a prefix if you cannot change it ?? All my personal tables have a different prefix from the Joomla ones, so pure PHP stuff is thus easier to write and use than Joomla stuff.

The default Joomla assumption is that all the tables related to a single site will use the same prefix - you can set this when you install the site - but the default is 'jos_' and that's what you will most often see. This approach means that you can run multiple sites from the same database schema by setting each to have a distinct prefix.

So that the Joomla functions run correctly regardless of prefix the MySQL command use a proxy prefix of #__ and this is changed to the appropriate prefix for the site when the command is executed. You are of course free to use your own prefix for local tables - but this approach won't work for any extension that might be installed on multiple sites.

Hard to tell what the effect of 'Bob's method' and 'Max's method' are without being reminded of the code and the context.

The setVar/getVar combination is probably checking to see if there is a value set in the $_POST array and updating it if there is - those two methods themselves have nothing to do with dates.

The ChronoForms Autogenerated code will add any entries in the $_POST array to the database if the array indices (i.e. field names) and the database table column names match - it does not do any type casting so the write can fail or give an unexpected result!

Bob
This topic is locked and no more replies can be posted.