---
title: "Date-problem"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/71285-date-problem"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Jontto"
published: "2003-03-17T08:16:16.000Z"
updated: "2003-03-18T09:18:43.000Z"
replies: 7
views: 253
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/71285-date-problem"
---

# Date-problem

## #1 — Jontto, 2003-03-17T08:16Z

Varför får jag att februari 2004 har 31 dagar med date()? Egentligen har den juh 29....

Apache 1.3.20 (Win32) - PHP 4.2.3

```php
$totalMonthDays = date("t",mktime(0,0,0,2,1,2004));
```

 

MVH å önskan om snabbt svar,
Jontto

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

## #2 — Nexus86, 2003-03-17T08:26Z

Enligt php's manual:

```php
$totalMonthDays = mktime(0,0,0,3,0,2004);
```

Mao skriv dag som 0 UTAN date och skriv månad + 1.

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

## #3 — Jontto, 2003-03-17T08:26Z

Blir det inte sista dagen i januari då?

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

## #4 — Jontto, 2003-03-17T08:27Z

har ingen server nära till hands så kan inte testa genast, men ska försöka senare ifall du menar att det funckar...

\*tackar å bockar\*

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

## #5 — Nexus86, 2003-03-17T08:28Z

> **phps manual skrev:**
>
> The last day of any given month can be expressed as the "0" day of the next month, not the -1 day. Both of the following examples will produce the string "The last day in Feb 2000 is: 29". Exempel 2. Last day of next month
> 
>
>
> ```php
> $lastday = mktime (0,0,0,3,0,2000);
> echo strftime ("Last day in Feb 2000 is: %d", $lastday);
>      
> $lastday = mktime (0,0,0,4,-31,2000);
> echo strftime ("Last day in Feb 2000 is: %d", $lastday);
> ```

EDIT // Jag menade mktime(0,0,0,3,0,2004). Ska rätta till det där också. :r

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

## #6 — Jontto, 2003-03-17T08:30Z

ok, men borde inte min kod ändå fungera?

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

## #7 — Nexus86, 2003-03-17T08:52Z

Jo egentligen. Är inte så insatt i date men det borde den nog.

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

## #8 — Jontto, 2003-03-18T09:18Z

äh...vet inte vad som var fel, men skrev om hela koden lite för att snygga upp å så försvann felet. \*human-error\*

Thänx enivei

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

---

Tråden på webben: https://www.webforum.nu/amne/php/71285-date-problem
