Rreceiving separate date and time inputs, validating separately, and formatting as one.

Hi, With two timezones implied (source, and target). What is the more straightfoward way to achieve the following.

  1. User inputs ‘date’ and ‘time’ attributes. (in the target timezone)

  2. SearchModel validates those attributes according a given format (we want to know each of them is correctly formatted according to the target timezone)

  3. SearchModel merges ‘date’ and ‘time’ to a ‘datetime’ attribute.

  4. SearchModel formats ‘datetime’ to a source language (conversion due to timezone is implied). (validation is not needed).

  5. SearchModel querys ‘datetime’ against db.


  • At 3, for the merging, string concatenation is enough?

  • Where should 3 and 4 occur? at searchmodel::afterValidate() ? and with yii::$app->formater->asDatetime(); ?

How do you people handle separate user inputs for date and time? or do you always get’em as one datime value?