Skip to content

Instantly share code, notes, and snippets.

@Schlaefer
Last active August 29, 2015 14:25
Show Gist options
  • Save Schlaefer/61ff394ef7f8929826cf to your computer and use it in GitHub Desktop.
Save Schlaefer/61ff394ef7f8929826cf to your computer and use it in GitHub Desktop.
// mysql queries
INSERT INTO `tests` (`stamp`) VALUES ('2015-07-01T00:00:00+0000');
INSERT INTO `tests` (`stamp`) VALUES ('2015-07-01 00:00:00');
INSERT INTO `tests` (`stamp`) VALUES ('2015-07-01T00:00:00+0400');
INSERT INTO `tests` (`stamp`) VALUES ('2015-07-01 00:00:00');
<?php
date_default_timezone_set('UTC');
$table = TableRegistry::get('tests');
$table->deleteAll(['id >' => '0']);
$entity = $table->newEntity(
[
'stamp' => '2015-07-01T00:00:00+0000'
]
);
$table->save($entity);
$entity = $table->newEntity(
[
'stamp' => new Time('2015-07-01T00:00:00+0000')
]
);
$table->save($entity);
$entity = $table->newEntity(
[
'stamp' => '2015-07-01T00:00:00+0400'
]
);
$table->save($entity);
$entity = $table->newEntity(
[
'stamp' => new Time('2015-07-01T00:00:00+0400')
]
);
$table->save($entity);
CREATE TABLE `tests` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`stamp` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
id stamp
70 2015-07-01 00:00:00
71 2015-07-01 00:00:00
72 2015-07-01 00:00:00
73 2015-07-01 00:00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment