Metadata date field is being represented differently in PHP


(Richard Crompton) #1

Hi

 

We have 5 metadata fields that represent scheduled date and each have the Display Format set to d/m/Y H:i:s, but if I want to manipulate them in jQuery they switch to American format.

 

Metadata setting - Display Format (Figure 1 of attachment)

 

They are maintained through a Simple Edit using:

<div class="date-selector">%metadata-F_17093%</div>

 

Displayed on Simple Edit (Figure 2 of attachment)

 

Stored as (Figure 3 of attachment)

 

On the general display page, I build a key pair object to manipulate once the page is ready:

        <script type="text/javascript">             today = %globals_date^date_format:Ymd%;
            dateObj = { %globals_asset_metadata_ScheduleDatesOne^date_format:Ymd% : '%globals_asset_metadata_ScheduleDatesOne^date_format:r%',
                        %globals_asset_metadata_ScheduleDatesTwo^date_format:Ymd% : '%globals_asset_metadata_ScheduleDatesTwo^date_format:r%',
                        %globals_asset_metadata_ScheduleDatesThree^date_format:Ymd% : '%globals_asset_metadata_ScheduleDatesThree^date_format:r%',
                        %globals_asset_metadata_ScheduleDatesFour^date_format:Ymd% : '%globals_asset_metadata_ScheduleDatesFour^date_format:r%',
                        %globals_asset_metadata_ScheduleDatesFive^date_format:Ymd% : '%globals_asset_metadata_ScheduleDatesFive^date_format:r%' };
        </script>

 

When I manipulate these fields (using Firebug) they appear as (Figure 4 of attachment)

 

 

Any ideas why? Date formatting issues.doc (36.5 KB)


(Aleks Bochniak) #2

try setting your metadata date format to dd-mm-yyyy, then your keyword modifiers will work properly


(Bart Banda) #3

The best format for metadata date fields is actually Y-m-d h:i:s which prints an ISO standard date format of 2014-01-01 12:12:12 

 

Your date keyword modifiers should then work properly. 


(Richard Crompton) #4

Thanks Bart, that did the trick