tags:

views:

84

answers:

4
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.

+2  A: 

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.

RageZ
Seems only you got what I mean.But can you verify it?
Mask
I think like pointed out other person it might something to do with the double byte. but really no way to check that apart inspecting the php source code
RageZ
@Mask, just try echo strtotime( date("Y年m月d日") );
x2
@x2: thanks for the remark it return false
RageZ
+2  A: 

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

Konamiman
and ? what is has to do with the w, day of the week being different?
RageZ
He just said "second is bigger". I'm not sure what he meant so I took a possible interpretation.
Konamiman
What did I say that is incorrect to deserve the downvote?
Konamiman
@Konamiman: sorry my bad, not me for the downvote.
RageZ
A: 

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

Kaivosukeltaja
+1  A: 

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")));