Gutenberg Block referencer

WordPress Gutenberg Håndbog

Around the web

Paid tutorials, courses and books

Indlæg for ContentTools, edit

Tekst for test-indlæg.

Overskrifter kan redigeres.

Create user and set privileges in MySQL/MariaDB

Connect to MySQL/MariaDB
sudo mysql -u root

Create database

Create database
mysql> CREATE DATABASE IF NOT EXISTS your_database_name;

Add User

Create user
CREATE USER 'set-your-username'@'%' IDENTIFIED BY 'set-your-password';

Note. ‘set-your-username’@’%’ equals ‘username’@’host/domain’. localhost eg. ‘username’@’localhost’ can be used if mysql is only accessed from the same server that’s running the script.

Grant permissions to user ( All databases )
GRANT ALL PRIVILEGES ON *.* TO 'your-username'@'%';

Note.1 *.* means all databases and all tables. use dbname.* to restrict the user to a single database and dbname.tablename to restrict both the database and a table.
Note.2 % is a wildcard matching all domains.

Grant permissions to user ( Single database )
GRANT ALL PRIVILEGES ON dbname.* TO 'your-username'@'%';

Flush privileges
FLUSH PRIVILEGES;

 

Sources

Helper commands

View databases
SHOW DATABASES;

 

View users
SELECT host, user, password FROM mysql.user;

 

View user privileges
SHOW GRANTS FOR 'your-username'@'localhost';

Formater datoer i PHP

Konventer et eksisterende dato format til et andet.

For eksempel

2017-12-31 00:00:00 til 31. december 2017

PHP DateTime

$DateTimeObj = DateTime::createFromFormat('Y-m-d H:i:s', $dateString);
$newDateString = $DateTimeObj->format('j. F Y');

echo newDateString;

d : Tocifret dag, 01 – 31
j : Etcifret dag, 1 – 31
m : Tocifret måned, 01 – 12
F : Måned angivet med fulde navn, Januar – December.
Y : firecifret år, 1694

H : Tocifret timer, 00 – 23
i : Tocifret minutter, 00 – 59
s : Tocifret sekunder, 00 – 59

Se den komplette liste på php.net

Oversæt måned eller dag

Brug local, med DateTime og IntlDateFormatter

$dateTimeObj = new DateTime(‘2015-01-03 12:32:44’);
$dateFormatterObj = new IntlDateFormatter(‘da_DK’, IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
$dateFormatterObj->setPattern(‘d. MMMM yyyy’);

echo $dateFormatterObj->format($dateTimeObj);

 

http://php.net/manual/en/intldateformatter.formatobject.php

https://stackoverflow.com/questions/8744952/formatting-datetime-object-respecting-localegetdefault

Format referencer IntlDateFormatter: http://userguide.icu-project.org/formatparse/datetime

Kontakt

Confirmation icon

Har du spørgsmål til et projekt, eller ønsker du at tale en idé igennem?

I så fald er du velkommen til at ringe, eller sende mig en besked med dine spørgsmål.

  • Airplain icon Send besked

Mads Hansen
Vesterbro 13, baggård, stuen
5000, Odense C.

Tlf. 60 94 27 14
info@lmp.dk
cvr. 34 51 04 07