Welcome, Guest
Username: Password: Remember me

TOPIC: Use a Date or Integer(10) - Unix Timestamp

Use a Date or Integer(10) - Unix Timestamp 18 Dec 2011 05:17 #731

  • iconvisual
  • iconvisual's Avatar
  • Offline
  • Senior Member
  • Keen Joomla! 1.7 Developer
  • Posts: 53
  • Thank you received: 5
  • Karma: 1
Hello All,

My current project involves 'migrating' an existing PHP Web Based App to Joomla! 1.7 and I'm using Cook to create my Component.

As I'm creating the Tables (and there are some 20 or so of them) I'm not certain what to do with fields in my existing MySQL schema that have 'date' values and are formatted as INTEGER(10).

Should I build the Table in Cook using the DATE Data Type OR should I keep the fields as INTEGER?

Obviously I will be doing some calculations etc. in my Module and Component, so which is the best way ahead?

P.S. For those unfamiliar with Unix Time Stamp as a value please see: www.unixtimestamp.com

So, my existing Field has an Integer(10) such as 1311256800 which is calculated as 07 / 21 / 11 @ 9:00:00am EST

Thank you!

Ed.
Keen Joomla! and PHP/MySQL developer. Excited about J-Cook.
The administrator has disabled public write access.

Re: Use a Date or Integer(10) - Unix Timestamp 19 Dec 2011 14:01 #739

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Modify JDom for READING correcty the value, converting timestamp value to DateTime object.
- html.form.input.datetime
- html.fly.datetime
(From memory)

Modify the model of each concerned tables in the save() function in order to reformate in timestamp before to save.
If you have a lot of tables, write this converting functionality in the 'classes/jmodelitem.php' and all your models with herit this new function. You have a perfect example of what this abstrat JModel class is for.

Note : Be careful to override your data ONLY if is present in $POST. (because save() is used also for partial updates of fields)



Should work. Easy, no ?
Coding is now a piece of cake
Last Edit: 19 Dec 2011 14:03 by admin.
The administrator has disabled public write access.
Time to create page: 0.094 seconds

Get Started