Matzn Posted May 18, 2021 Share Posted May 18, 2021 Hi, i have two date fields. One stores in unix timestamp (ratingDate) the other as a normal date (googlePageSpeedDate). Both have the same settings! How can I influence the saving? The strange thing is that I can't get the unix timestamp by (Check is the FieldsetPage) $page->Check->getUnformatted('googlePageSpeedDate'); ProcessWire\FieldsetPage Object ( [id] => 9932 [name] => for-page-1072 [parent] => /admin_panel_page/repeaters/for-field-389/ [template] => repeater_Check [name1067] => [status1067] => 1 [googlePageSpeedDate] => 2021-05-17 00:00:00 [data] => Array ( [name1067] => [status1067] => 1 [googlePageSpeedDate] => 2021-05-17 00:00:00 ) ) ProcessWire\RepeaterPage Object ( [id] => 1137 [name] => 1618998033-3988-1 [parent] => /admin_panel_page/repeaters/for-field-312/for-page-1075/ [template] => repeater_businessProvider [name1067] => [status1067] => 1 [isSocialMedia] => 0 [businessProviderPage] => (Page) 1132 [rating] => 4,6 [ratingUsers] => 10 [ratingDate] => 1621240175 [urlTo] => https://maps.google.com/?cid=11132489695980159614 [reviewUrl] => [data] => Array ( [name1067] => [status1067] => 1 [isSocialMedia] => 0 [businessProviderPage] => ProcessWire\Page Object Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 18, 2021 Share Posted May 18, 2021 $page->getUnformatted('yourDateField'); The example above should actually result in a timestamp. At least that's what I use each and everywhere. https://processwire.com/api/ref/page/get-unformatted/ https://cheatsheet.processwire.com/page/built-in-methods-reference/page-getunformatted-field/ Link to comment Share on other sites More sharing options...
Matzn Posted May 19, 2021 Author Share Posted May 19, 2021 @wbmnfktr ic know this postes, but no way to get the unix timestamp by $page->getUnformatted('yourDateField'); I also used it in several projects, but now the output must be set for date field to none. So i use this date field only as $page->yourDateField; I also don't understand why one field is save as unix and the other not (same settings). Link to comment Share on other sites More sharing options...
Macrura Posted May 19, 2021 Share Posted May 19, 2021 you must have some bug or other issue; $page->getUnformatted('date_field'); always returns a unix timestamp. All datetime fields are stored in the DB as datetime which is not unix timestamp (it is Y-m-d H:i:s), but that database value is converted to the unix timestamp for the unformatted value of a datetime field; You can see this in the sleepValue and wakeupValue for the fieldtype, which converts it like this: return is_int($value) ? date('Y-m-d H:i:s', $value) : ''; Link to comment Share on other sites More sharing options...
Matzn Posted May 20, 2021 Author Share Posted May 20, 2021 @Macrura I have tested something. If add the date field to page or repeater page it works, but not to a fieldsetpage: echo "\nFieldsetPage:\n"; echo $page->Check->ratingDate; echo "\n"; echo $page->Check->getUnformatted("ratingDate"); echo "\nPage:\n"; echo $page->ratingDate; echo "\n"; echo $page->getUnformatted("ratingDate"); echo "\nRepeaterPage:\n"; echo $page->About->businessProvider->first()->ratingDate; echo "\n"; echo $page->About->businessProvider->first()->getUnformatted("ratingDate"); Live Result: FieldsetPage: 19.05.2021 19.05.2021 Page: 19.05.2021 1621375200 RepeaterPage: 19.05.2021 1621429619 It's a bug or i can set somthing? Link to comment Share on other sites More sharing options...
netcarver Posted May 20, 2021 Share Posted May 20, 2021 Sounds like a possible bug in FieldsetPage - can you open an issue for this in the issues repository please. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now