This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Eliminar caracterse no alfanuméricos de una cadena | |
preg_replace("/[^A-Za-z0-9]/", '', $string); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ultimo día del mes actual | |
$ultimoDia = date('Y/m/t').' 23:59:59'; | |
echo $ultimoDia; | |
// Sumar segundos a una fecha | |
$time = strtotime('2013-09-18 11:00:00+25200 seconds'); | |
echo date('H:i',$time); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Comprobar si el fichero trae BOM | |
$bom = pack("CCC", 0xef, 0xbb, 0xbf); | |
if (0 == strncmp($json, $bom, 3)) { | |
$json = substr($json, 3); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteDirectoryRecursive($dirPath) { | |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) { | |
$path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname()); | |
} | |
rmdir($dirPath); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, nombre, apellidos, SUBSTR(CONCAT('0000',codigo),-4) as CDB FROM empleados WHERE codigo REGEXP '^-?[0-9]+$' ORDER BY CAST(codigo AS UNSIGNED) ASC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM tabla ORDER BY FIELD(tipo,'ANTES','DURANTE','DESPUES') ASC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Crear nuevo campo | |
ALTER TABLE `test` ADD COLUMN `ts_year_month` int(11); | |
-- Insertar valores en el campo para los registros actuales | |
UPDATE `test` SET ts_year_month = DATE_FORMAT(fecha,'%Y%m'); | |
-- Actualizar la definición de la nueva columna | |
ALTER TABLE `test` MODIFY `ts_year_month` int(11) NOT NULL; | |
-- Añadir el nuevo campo al índice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="modal fade" id="modal-id" tabindex="-1" role="dialog"> | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
<h4>Título</h4> | |
</div> | |
<div class="modal-body" style="max-height: calc(100vh - 212px);overflow-y: auto;"> | |
<div class="list-group"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteRule ^loquesea$ http://www.otrodominio.com/otrodirectorio [R=301,NC,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> SELECT CURRENT_TIMESTAMP(); | |
+---------------------+ | |
| CURRENT_TIMESTAMP() | | |
+---------------------+ | |
| 2016-04-12 14:31:59 | | |
+---------------------+ | |
1 row in set | |
mysql> SELECT @@global.time_zone, @@session.time_zone; | |
+--------------------+---------------------+ |