Re: A "bad" Unix Timestamp?

This is a discussion on Re: A "bad" Unix Timestamp? within the PHP Language forums, part of the PHP Programming Forums category; Warren Oates wrote: <snip> > That's all fine. Then I think, well, it would be nice if ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-21-2004
Pedro Graca
 
Posts: n/a
Default Re: A "bad" Unix Timestamp?

Warren Oates wrote:
<snip>
> That's all fine. Then I think, well, it would be nice if I could tell
> the user something like "there's not that may days in $m" and I should
> be able to use strtotime() and date() -- but it turns out (and rightly
> so) that you can't create a "bad" Unix timestamp.
>
> For instance,
>
> date ("F d Y",strtotime("2004-09-31"));
>
> will return October 01 2004 and fwiw, so will
>
> date ("F d Y",mktime(0,0,0,9,31,2004));
>
> I can write a switch, of course, and there's only 5 cases (30 days
> hath September etc., plus February needs to be dealt with). It
> intrigues me, though, and I wondered if anyone else had played with it.


Something like this?

<?php
$user_date = '2004-09-31';
if (date('Y-m-d', strtotime($user_date)) != $user_date) {/* bad date */}
?>
--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0