MySQL DATETIME created_at and updated_at
431375
public function created_at($row)
    {
        if (is_object($row))
        {
            $row->created_at = date('Y-m-d H:i:s');
        }
        else
        {
            $row['created_at'] = date('Y-m-d H:i:s');
        }

        return $row;
    }
1172217
public function statSumHour($db_prefix, $add_time = null)
    {
        $sql = "select sum(num) as num,v1,v2,v3,md5_v3 from {$db_prefix}stat where add_time = :add_time group by md5_v3";
        if ($add_time === null) {
            $add_time = date('Y-m-d H', strtotime('-1 hour'));
        }
        $hour_arr = $this->db()->getAll($sql, array('add_time' => $add_time));

        $sql1 = "update {$db_prefix}stat_hour set num = :num where md5 = :md5";
        $sql2 = "insert into {$db_prefix}stat_hour(num,v1,v2,v3,md5,add_time) values (:num,:v1,:v2,:v3,:md5,:add_time)";
        foreach ($hour_arr as $v) {

            if ($this->isExist($v['md5_v3'], 'v3', $db_prefix)) {
                $this->db()->execute($sql1, array('num' => $v['num'], 'md5' => $v['md5_v3']));
            } else {
                $this->db()->execute($sql2,
                    array('num' => $v['num'], 'v1' => $v['v1'], 'v2' => $v['v2'], 'v3' => $v['v3'], 'md5' => $v['md5_v3'], 'add_time' => $add_time));
            }
        }

    }
121852
function fixDates(attrs) {
        var self = this;

        _.each(attrs, function each(value, key) {
            if (value !== null
                && schema.tables[self.tableName].hasOwnProperty(key)
                && schema.tables[self.tableName][key].type === 'dateTime') {
                attrs[key] = moment(value).format('YYYY-MM-DD HH:mm:ss');
            }
        });

        return attrs;
    }
854370
protected function timestampUpdate()
    {
        $this->updated = date('Y-m-d H:i:s');
        $this->id || $this->created = $this->updated;
    }
1371726
def set_updated_at
      if Dynamoid::Config.timestamps && !updated_at_changed?
        self.updated_at = DateTime.now.in_time_zone(Time.zone)
      end
    end
1112368
public static function makeUpdateSQL()
    {
        $tableName = self::getTableName();
        $setClause = "";
        $whereClause = "";
        $keysCount = count(self::$fields);
        $iterations = 1;

        foreach(self::$fields as $key => $val)
        {
            if($key == "id") {
                $whereClause = " WHERE id = ".$val;
            }
            else if($key != "result") {
                $setClause = $setClause.$key." = '".$val."'";

                if($keysCount > 2 && $iterations < $keysCount) {
                    $setClause = $setClause.", ";
                }
            }
            $iterations++;
        }

        $sql = "UPDATE ".$tableName." SET ".$setClause.$whereClause;

        return $sql;
    }
1098673
public function getDates()
    {
        $defaults = [static::CREATED_AT, static::UPDATED_AT];

        return $this->usesTimestamps() ? array_merge($this->dates, $defaults) : $this->dates;
    }
982312
private boolean setUpdated(Date lastUpdateTime) {
        // Because there is no gaurantee of order of delivery,
        // we want to ensure that we do not set the updated time if it was
        // earlier than the current updated time
        if (updated == null || updated.compareTo(lastUpdateTime) < 0) {
            updated = lastUpdateTime;
            return true;
        }
        return false;
    }
392972
public function getCreatedDate()
    {
        $rtn    = $this->data['created_date'];

        if (!empty($rtn)) {
            $rtn    = new \DateTime($rtn);
        }
        
        return $rtn;
    }
488238
def query_dated(num=8, kind='1'):
        '''
        
        '''
        return TabPost.select().where(
            TabPost.kind == kind
        ).order_by(
            TabPost.time_update.asc()
        ).limit(num)
191865
public function change()
    {
        $table = $this->table('widgets');
        $table->changeColumn('trashed', 'datetime', [
            'default' => null,
            'null' => true,
        ]);
        $table->update();

        // Update existing records to set null for non-deleted ones
        // NOTE: cast to char is needed for the mysql 5.7*!
        $count = $this->execute('UPDATE widgets SET trashed=NULL WHERE CAST(trashed AS CHAR(20)) = "0000-00-00 00:00:00"');
    }
270646
def convert_datetimes_to_timestamps(data, datetime_attrs):
    
    if not data:
        return data

    new_data = {}
    for key, value in data.items():
        if key in datetime_attrs and isinstance(value, datetime):
            new_key = datetime_attrs[key]
            new_data[new_key] = timestamp_from_dt(value)
        else:
            new_data[key] = value

    return new_data
1186009
def insert_at(df, sample_date, values):
    
    observed_dt = dt(datetime.now())
    return multi_index_insert_row(df, [sample_date, observed_dt], values)
790403
public function getCreatedAt() {
		$timestamp = filemtime($this->pathname);
		$time = new DateTime();
		$time->setTimestamp($timestamp);
		return $time;
	}
1359543
public function getCreated()
    {
        $rtn    = $this->data['created'];

        if (!empty($rtn)) {
            $rtn    = new \DateTime($rtn);
        }
        
        return $rtn;
    }
469916
public static function dateTimeSql2PHP($sqlField,&$hasTime=false)
	{
		// 3  2016-01-31 00:00:00 -> 01/01/2016 00:00:00
		// mysql always returns the date/datetime/timestmamp in ansi format.
		if ($sqlField === "" || $sqlField===null) {
			if (DaoOne::$dateEpoch===null) return null;
			return DateTime::createFromFormat('Y-m-d H:i:s.u',DaoOne::$dateEpoch);
		}
		if (strpos($sqlField, '.')) {
			// with date with time and microseconds
			$hasTime=true;
			return DateTime::createFromFormat('Y-m-d H:i:s.u', $sqlField);
		} else {
			if (strpos($sqlField, ':')) {
				// date with time
				$hasTime=true;
				return DateTime::createFromFormat('Y-m-d H:i:s', $sqlField);
			} else {
				// only date
				$hasTime=false;
				return DateTime::createFromFormat('Y-m-d', $sqlField);
			}
		}
	}
1286636
def timestamps(self, use_current=True):
        
        if use_current:
            self.timestamp("created_at").use_current()
            self.timestamp("updated_at").use_current()
        else:
            self.timestamp("created_at")
            self.timestamp("updated_at")