Mask
Mask

Reputation: 34207

Why it's different?

echo date("w",strtotime(date("Y-m-d")));
echo date("w",strtotime(date("Y年m月d日")));

Save it as utf8.You'll see the second is bigger than the first one.

Upvotes: 0

Views: 119

Answers (4)

user207675
user207675

Reputation: 74

The main problem is that strtotime is expection a valid date in US format ( readyble here http://php.net/manual/en/function.strtotime.php )

to solve this you could use the function strftime

    echo date("w",strftime(date("Y年m月d日")));
    echo date("w",strftime(date("Y-m-d")));

Upvotes: 1

RageZ
RageZ

Reputation: 27323

Mask,

most probably because strtotime is not able to parse properly the japanese formated date.

In my opinion, by reading the documentation it would accept date formated with - but that's not explicitly said.

trying var_dump(strtotime(date("Y年m月d日")); give false so like in the documentation the strtotime seems to fail to parse it.

so date apply on false which don't give the same result.

Upvotes: 2

Kaivosukeltaja
Kaivosukeltaja

Reputation: 15735

The Asian characters take up 2 or more bytes when represented in UTF-8, while dashes only take one byte.

Upvotes: 0

Konamiman
Konamiman

Reputation: 50313

If by "bigger" you mean "it uses more bytes", it's beacause UTF8 is an encoding with variable character size. A - character will be encoded with one single byte, while 年 will be encoded with at least two. See here: http://en.wikipedia.org/wiki/Utf8

Upvotes: 2

Related Questions