---
title: "Hämta dagens datum med PHP?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/188558-hämta-dagens-datum-med-php"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "kluringen"
published: "2011-12-08T10:49:28.000Z"
updated: "2011-12-08T13:13:04.000Z"
replies: 3
views: 1433
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/188558-hämta-dagens-datum-med-php"
---

# Hämta dagens datum med PHP?

## #1 — kluringen, 2011-12-08T10:49Z

Kan jag få tag på dagens datum med häjlp av PHP kod?
Tacksam för kodexempel.

Permalänk: https://www.webforum.nu/p/188558

## #2 — @nders, 2011-12-08T10:51Z

```php
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
$today = date("m.d.y");                         // 03.10.01
$today = date("j, n, Y");                       // 10, 3, 2001
$today = date("Ymd");                           // 20010310
$today = date('h-i-s, j-m-y, it is w Day');     // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // it is the 10th day.
$today = date("D M j G:i:s T Y");               // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');     // 17:03:18 m is month
$today = date("H:i:s");                         // 17:16:18
?>
```

Källa: <http://php.net/manual/en/function.date.php>

Never underestimate the power of Google.  :)

mvh

Permalänk: https://www.webforum.nu/p/2289321

## #3 — kluringen, 2011-12-08T11:22Z

Tak för supersnabb svar.

Permalänk: https://www.webforum.nu/p/2289322

## #4 — metalboy, 2011-12-08T13:13Z

Det finns även [strftime](http://www.php.net/strftime)(). Den funktionen tar hänsyn till vilken locale som är inställd på servern (eller via [setlocale](http://www.php.net/setlocale)())

Permalänk: https://www.webforum.nu/p/2289323

---

Tråden på webben: https://www.webforum.nu/amne/php/188558-hämta-dagens-datum-med-php
