Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

  • iconvisual
  • iconvisual's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Keen Joomla! 1.7 Developer
  • Posts: 53
  • Thank you received: 5
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.

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

Last edit: by admin.
  • Page:
  • 1
Time to create page: 0.073 seconds

Let me first state that this is an amazing and fascinating product exactly what I was looking for. In just a few hours (listening to the very well made and clearly understandable videos learning doing) I completed and installed my first component. I am now in the second refining phase. I will make a recommenation in JED. Thanks for the effort in creating such a great product. Incidentally some of the best Joomla extension I use are of French origin !
Giori (Forum)

Get Started