11 years ago
5
Topic

On the old forum I had posted a query on how to set the current date/time as the default value for the Calendar field...

I discovered that I could use the Datetime live value plugin to set the date automatically on the Calendar field...

The only problem is that it will only show the date using the UTC timezone where I need it to be UTC+10 - Australia/Melbourne.

I've double checked that php.in has the timezone set to 'Australia/Melbourne'

I've tried messing with a line from the Datetime plugin:

$live   =    JFactory::getDate()->format( $format );

... using recommendations from here - http://webamoeba.co.uk/blog/working-with-dates-in-joomla/ but nothing seems to work.

Any suggestions would be greatly appreciated.

Cheers

snaffle

Get a VIP membership
13 Posts
wisesiteguy
11 years ago
4
Level 1

Hi snaffle,

I too am trying to solve this one. Did you make any further progress?  At present I've got it to display Melbourne time (at least we're looking at the same city) by replacing line 44 of datetime.php with 

$live= JFactory::getDate('UTC', 'Australia/Melbourne')->format( $format );

A quick and dirty workaround. It'd still be great to be able to pull the default joomla timezone though, so I'm gonna keep trying. I'll let you know.

11 years ago
3
Level 2

Hi wisesiteguy,

I ended up making progress but ultimately by not using the Date/Time plugin.

I was trying to get the current date and time to appear as the default value in the Calendar plugin, and finally found on the forums that you can do this just by putting the word "now" in the Default Value field of the of the Calendar plugin - and it respects the timezone set in Joomla.

So I ended up not having to use the Date/Time plugin - though I still think it should support the timezone setting rather than just UTC. Thanks for sharing that code, at least I can force it to Melbourne or another timezone if I need to use it again.

Cheers

13 Posts
wisesiteguy
11 years ago
0
Level 3

Snaffle,

I'd come across that myself a while back but hadn't remembered - thanks for the reminder. I'll have a look and try to implement that for my own needs - I just want a hidden value for an email sent date. Not sure why I hadn't thought to use a calendar, doh :j

27 Posts
jsfernando
11 years ago
1
Level 3

Snaffle,

I used his recommendation because tbém need the field with a calendar date to save the day, but with the type hidden, without the need for the user to fill ...
So even putting the word "now" in the default option ... nothing happened ... the date field in the table is still recording zero ...
What would be another option that you used ... can give an example?

tks,

11 years ago
0
Level 4

Question... are you trying to enter "now" in the default value for the Calendar plugin or the Date/Time plugin?

As far as I now it only works with the Calendar plugin.

I'm also not sure if you can make the Calendar plugin field "hidden" but I would have thought that you can.

Get a VIP membership