如何在两个日期之间获得一半的DateTime?

时间:2016-12-16 07:33:54

标签: php codeigniter

我有当前的日期时间和投放日期时间

$del_time = $this->input->post('bid_time');    
date_default_timezone_set('Asia/Kolkata');
        $now = date('Y-m-d H:i:s');

我希望在Y-m-d H:i:s期间的当前日期时间和交付日期时间之间的确切一半的日期时间

1 个答案:

答案 0 :(得分:2)

您可以使用以下代码

case class User(id: Long, firstName: String, lastName: String, mobile: Long, email: String)

object User {
  private val seq = new AtomicLong

  def apply(firstName: String, lastName: String, mobile: Long, email: String): User = {
    User(seq.incrementAndGet(), firstName, lastName, mobile, email)
  }

  def mapperTo(
    id: Long, firstName: String,
    lastName: String, mobile: Long, email: String
  ) = apply(id, firstName, lastName, mobile, email)

}

class UserTableDef(tag: Tag) extends Table[User](tag, "user") {

  def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
  def firstName = column[String]("first_name")
  def lastName = column[String]("last_name")
  def mobile = column[Long]("mobile")
  def email = column[String]("email")

  override def * =
    (id, firstName, lastName, mobile, email) <> ((User.mapperTo _).tupled, User.unapply)

}

由于