Buy Now
Sign in

Creation time saved in database: offset with timezone?

jj135 , July 31 2017
Answered
jj135
Hi!

I have a form that saves data to a database table. I use created:{date:Y-m-d H:i:s} in the field 'Data override on Insert'. This inserts the current date/time in the database table. Works fine, but I was wondering if it is possible to save this date/time in our own timezone?

Kind regards,
Jip
admin
Hi Jip,

Its better to save the time in GMT but display it later in whatever timezone you want:
{date.-0500:Y-m-d H:i:s$(data:time)}


Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
jj135
OK, thanks for this Max.

We store this value in the database (GMT - default) but after this we extract the data to a csv file. In the CSV file I would like to have the 'local' time, so that's the 'display' part of the date. I don't think it is possible to do this in the CSV export settings?

It would be best to actually use the timezone set in Joomla to 'display' the dat in the CSV file. Maybe there would be a way to convert the date between saving it in the database and exporting it to the CSV? But that would make it a quit more complex I guess.

I could also just let the client know he has to be aware the time in the CSV is GMT ;-) It's not a big deal!

Thanks so far!
admin
Hi Jip,

You can modify the date before the data is added to the CSV using some PHP code, but the better here is to tell the client that dates are in GMT time, maybe they need to import it later into database ?

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
jj135
I think we'll just leave it as it is and tell the client the have dot the math themselves for now ;-) And indeed, if they ever need to import this in to a database this will keep it GMT.

Thanks Max.
admin
Hi Jip,

No problems!

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
P
PaulSandman
I'm loving your forums! Thank you for all you do. I was trying to time-stamp my email template and from this thread, I came up with this:

Submitted by: <b>{ip:}</b> on <b>{date.-0500:F jS, Y}</b> at <b>{date.-0500:g:ia$(data:time)}</b> EST


This works great for me but I took your code to make it so I wanted to say thank you!


-Sandman