Forums

Unix Timestamp?

oculusmm 14 Sep, 2011
Hi,

I have some forms being saved to the database however the date field is showing up as for example.

1315428452 which to me is very much like a unix timestamp. On checking this converts to Wed, 07 Sep 2011 20:47:32 GMT. How can I have the date field store or send out the correct format to the customer? Presently the fields are set as VARCHAR.

Thanks in advance

PS forgot to say both items on the form saving unix timestamps are using the mootools calendar item.
GreyHead 15 Sep, 2011
Hi oculusmm,

You don't say how you have the date-picker configured??

Bob
oculusmm 03 Nov, 2011
Hi,

Sorry just seem my open ticket here.

Form is set up as follows
<div class="row2"><input id="frmCallTime"  class="select_haymarket" name="select_haymarket_date" /></div>


DateTime Picker selector
has the following two class assigned one for each DateTime Picker

select_haymarket, select_airport

On The page

<![CDATA[
window.addEvent('load', function() {
new DatePicker('.cf_date_picker', {pickerClass: 'datepicker_dashboard', inputOutputFormat: 'Y-m-d H:i:s', allowEmpty: true});
new DatePicker('.cf_datetime_picker', {pickerClass: 'datepicker_dashboard', inputOutputFormat: 'Y-m-d H:i:s', timePicker: true, allowEmpty: true, format: 'd-m-Y H:i:s'});

new DatePicker('.cf_time_picker', {pickerClass: 'datepicker_dashboard', inputOutputFormat: 'Y-m-d H:i:s', timePickerOnly: true, allowEmpty: true, format: 'd-m-Y H:i:s'});
new DatePicker('.select_haymarket, select_airport', {pickerClass: 'datepicker_dashboard', inputOutputFormat: 'Y-m-d H:i:s'});
							});
		//]]>
		
		//<![CDATA[
window.addEvent('load', function() {
	new DatePicker('.select_haymarket', { pickerClass: 'datepicker_dashboard' });
	new DatePicker('.select_airport', { pickerClass: 'datepicker_dashboard' });
});		//]]>


Database Table set as VARCHAR
GreyHead 03 Nov, 2011
Hi oculusmm ,

Personally I prefer to save dates as type DATE, if you save them (or convert before saving) as Y-m-d this should work OK.

Bob
SantosMM 24 Apr, 2012
Hi Bob,

I've been looking for an answer to the following situation (similar to this UNIX format issue)

I set up a form with the DATE field as follows:

<div class="ccms_form_element cfdiv_datetime" id="fecha_prueba_container_div"><label>Fecha de la prueba*:</label><input name="input_fecha_prueba" type="text" value="" class="date date_toggled" validate['required','target:input_fecha_prueba_clone_id'] cf_date_picker style="display: inline" title="Fecha de la prueba" />
<img src="components/com_chronoforms/css/formcheck/theme/classic/img/calendar.gif" class="date_toggler" style="position: relative; top: 3px; margin-left: 4px;" />
<div class="clear"></div><div id="error-message-fecha_prueba"></div></div>


In the General Settings section:
DateTime Picker config:
startView: startView:'month', format: 'd M Y', allowEmpty: false


I have declared a JavaScript event at On Load (Load JS):

window.addEvent('load', function() {
	new DatePicker('.date_toggled', {
		pickerClass: 'datepicker_dashboard',
		allowEmpty: false,
		toggleElements: '.date_toggler',
                format: 'd M Y',
                startView: 'month'
	});
});


And at the end of each record obtained through the form I get the date in UNIX
"1335217230"


How to convert the result to
"24 Abr 2012"
or similar at database registry and email sended??

Thanks.
oculusmm 24 Apr, 2012
Hi,

The following worked for me however this also has a timepicker attached. I would guess that removing
timePicker: true, and changing the format from
inputOutputFormat: 'Y-m-d H:i' to inputOutputFormat: 'Y-m-d' would give you the same result. This seems to work in converting Unix to a readable format.

window.addEvent('load', function() {
	new DatePicker('.select_haymarket', {
		pickerClass: 'datepicker_dashboard',
		timePicker: true, 
		inputOutputFormat: 'Y-m-d H:i', 
		allowEmpty: true
	});
});


The result on the database table is
select_haymarket_date 2011-11-01 11:16:51
SantosMM 24 Apr, 2012
Thanks oculusmm.. SOLVED!!

Great. Saludos.
This topic is locked and no more replies can be posted.