Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
en:create:functions:convertdatetime [12.12.2014 11:48] alexander.ritteren:create:functions:convertdatetime [12.12.2014 12:08] – [convertDateTime()] alexander.ritter
Line 1: Line 1:
 ====== convertDateTime() ====== ====== convertDateTime() ======
  
-''mixed **convertDateTime**(mixed //dateTime//, [string //formatDateTime//], [string //formatSpecificaton//])''+''mixed **convertDateTime**(mixed //dateTime//, [string //formatDateTime//], [string //formatOutput//])''
  
 The function ''convertDateTime()'' converts a date or a timestamp into a different date or timestamp. The function ''convertDateTime()'' converts a date or a timestamp into a different date or timestamp.
Line 7: Line 7:
   * //dateTime//\\ A Unix timestamp (e.g. ''1418045461'') or a string describing a date and/or a time (e.g. ''8.12.2014 14:31''').    * //dateTime//\\ A Unix timestamp (e.g. ''1418045461'') or a string describing a date and/or a time (e.g. ''8.12.2014 14:31'''). 
   * //formatDateTime// (optional)    * //formatDateTime// (optional) 
-    * Not specified or ''null'' -- automatically interprets the //dateTime//, as long as the usual date and time notation follows. For example, "1.4.", "4/1/2014", "16:30", "1.4.2014 16:30".  +    * Not specified or ''nil'' -- automatically renders the //dateTime//, as long as the usual date and time notation follows. For example, "1.4.", "4/1/2014", "16:30", "1.4.2014 16:30".  
-    * Definition of formatting according to procedure in PHP ''[[http://php.net/manual/de/datetime.createfromformat.php|DateTime::createFromFormat()]]'' (e.g. '''d.m.Y H:i''')  +    * Definition of format according to procedure in PHP ''[[http://php.net/manual/de/datetime.createfromformat.php|DateTime::createFromFormat()]]'' (e.g. '''d.m.Y H:i''')  
-  * //formatSpecification// (optional) +  * //formatOutput// (optional) 
-    * Not specified or ''null'' -- returns a Unix timestamp. +    * Not specified or ''nil'' -- returns a Unix timestamp. 
-    * Definition of formatting according to PHP function ''[[http://php.net/manual/en/function.date.php|date()]]'' (z.B. '''d.m.Y H:i''').+    * Definition of format according to PHP function ''[[http://php.net/manual/en/function.date.php|date()]]'' (z.B. '''d.m.Y H:i''').
  
-===== Beispiel =====+===== Example =====
  
-Der Befragte wurd in der offenen Texteingabe "AB01_01" um eine Datums- und Zeitangabe gebetenwann er zuletzt ferngesehen hatDiese Angabe sollte nach der Vorgabe "Stunde:Minute" (for den aktuellen Tagoder "Tag.Monat Stunde:Minutefür frühere Tage erfolgen.+In the text input "AB01_01", the respondent was asked to give the date and time of when he last watched televisionThe information should be specified as "hour:minute" (for the current dayor "day.month hour:minutefor previous days. 
 + 
 +The following PHP code is put on the page after question "AB01" at the very top. If the input cannot be recognized as a valid date/time, the text element "date error" is displayed the and the question shown again using ''[[:en:create:functions:repeatpage|repeatPage()]]'' 
  
-Der folgende PHP-Code wird auf der Seite nach Frage "AB01" ganz oben platziert. Falls die Eingabe nicht als gültige Datums-Zeit-Angabe interpretiert werden konnte, wird der Textbaustein "datum-fehler" angezeigt und die Frage mitts ''[[:de:create:functions:repeatpage|repeatPage()]]'' erneut anegezeigt. 
  
 <code php> <code php>
 if (convertDateTime(value('AB01_01')) == false) { if (convertDateTime(value('AB01_01')) == false) {
-  text('datum-fehler');+  text('dateerror');
   repeatPage();   repeatPage();
 } }
 </code> </code>
  
-Weiter hinten im Fragebogen soll dieses Datum nun im standardisierten Format "Tag.Monat.Jahr Stunde:Minuteangezeigt werden. Für die Anzeige wird in einer Frage der Platzhalter %datumverwendetDer folgende PHP-Code wird über der Frage (oder auch schon weiter vorneplatziert.+This date should be displayed in the standardized format "day.month.year hour:minutefurther on in the questionnaire. The placeholder %dateis used in a question in order to display thisThe following PHP code is put above the question (or may already be above). 
  
 <code php> <code php>
-$eingabe = value('AB01_01'); +$input = value('AB01_01'); 
-$ausgabe = convertDateTime($eingabenull, 'd.m.Y H:i'); +$output = convertDateTime($inputnil, 'd.m.Y H:i'); 
-replace('%datum%', $ausgabe);+replace('%date%', $output);
 </code> </code>
en/create/functions/convertdatetime.txt · Last modified: 25.08.2020 11:47 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki