How to assign value to attribute of type date?

Author Message

Ilya Sazonov

Saturday 06 November 2010 5:58:48 am

I have a class, which has an attribute of type date. And now I'm trying to import objects of that class to my site. With PHP. Everything is ok, but date is always 01/01/1970.

To specify date I do the following.

$attributesData['publication_date'] = '01/11/2010';

Maybe that's not the right way to specify date? Which is the right way then?

Heath

Saturday 06 November 2010 6:27:43 am

Hello Ilya,

Try converting your date to a timestamp before storing. Dates are stored as timestamps.

http://ezpedia.org/ez/simple_fromstring_and_tostring_interface_for_attributes

Cheers,

Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Ilya Sazonov

Saturday 06 November 2010 6:39:01 am

Wow! It really helped! Thank's a lot!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 00:38:31
Script start
Timing: Jan 31 2025 00:38:31
Module start 'layout'
Timing: Jan 31 2025 00:38:31
Module start 'content'
Timing: Jan 31 2025 00:38:31
Module end 'content'
Timing: Jan 31 2025 00:38:31
Script end

Main resources:

Total runtime0.0212 sec
Peak memory usage8,192.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.2656151.2266
Module start 'layout' 0.00500.0032 739.4922220.7266
Module start 'content' 0.00820.0114 960.2188997.7578
Module end 'content' 0.01960.0016 1,957.976629.9766
Script end 0.0212  1,987.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002612.2470140.0002
Check MTime0.00115.1917140.0001
Mysql Total
Database connection0.00073.134810.0007
Mysqli_queries0.00219.725930.0007
Looping result0.00000.052810.0000
Template Total0.00115.310.0011
Template load0.00094.252010.0009
Template processing0.00021.050910.0002
Override
Cache load0.00062.904410.0006
General
dbfile0.00094.355480.0001
String conversion0.00000.040540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs