date/time attribute by default

Submitted by timecl on 2010-10-27

Hi,

I've a question on the date/time attribute. I've seen it's possible to assign a date by default but how can I do to make this default date as the date/time of the current day.

Thank you
Vincent

For people looking for this solution too I've found a dirty trick :

just add this in validation.inc.php in wi_parse_definition function, just before return info :

if($info['default']=='DATETIME')
	$info['default']=strftime('%Y-%m-%d %H:%M:%S', mktime(date('H'), 0, 0, date('m'), date('d'), date('y')));

And in the database, in attr_type table put DATETIME default="DATETIME" time=1 instead of the attribute def

Another solution would be to run a cron each day at midnight and update the value in attr_def with the cureent day.

It's a good idea. I will add it to the TODO list for version 1.0.

Regards,
Michał

Thanks :)
Can be used for filters as well. For example I can add the attribute "due date" and add a view showing all the issues with a due date resolution earlier than today.

Exactly. Filters in version 1.0-alpha2 already have this capability - you can use "[Today]" or "[Today]-7" (meaning 7 days ago) for date/time attributes; also "[Me]" for user attributes. I just didn't think before that the same could be used for the initial values.

Regards,
Michał

That's great ! I should read the manual :)

Btw thank you for this application which is fantastic !
I'm running the Alpha 2 version with MSSQL server/IIS6 and no issues so far