[nycphp-talk] Formatting dates
Jeremy Hise
jhise at distantworker.com
Wed May 15 08:32:25 EDT 2002
Hi!
I'm not gonna go into details here, but just about all PHP date
functions use the unix timestamp..which may seem a little odd if you are
coming from M$. However, this turns out to be great because it actually
eleminates the problem of going into the next month.
For instance, to print the date, you say something like:
print (date("M Y"));
This will give you "May 2002";
Now, you can use a function called mktime() like this:
$new_timestamp = mktime(0, 0, 0, 5, 15, 2002);
Now if you say,
print (date("M d Y", $new_timestamp));
You will get:
"May 15 2002".
The "next month" problem is solved because if you say,
$new_timestamp = mktime(0,0,0,5,32,2002);
You will get
June 1 2002
Cool huh?
Good luck!
Jeremy
NOTE: Some syntax may be off a bit, but use PHP.net as your reference.
You can type in http://www.php.net/mktime and it will redirect you to
the function definition for mktime(), etc.
On Tue, 2002-05-14 at 23:40, jose sanchez wrote:
> Hello:
>
> I would like to know how I can use dates in PHP.
>
> This is what I would like to accomplish:
>
> First I would like to assign a starting date, for
> example:
> 5/11/02.
>
> I would like to add seven days to it so it will be
> Sat. May 18th and one day so it can be Sun. May 19th.
>
> I would like to do this for every week. At the same
> time, assign a week number according to the date. For
> example; May 11th and 12th would be week #1. Now, May
> 18th and 19th would be week #2 and so on...
>
> I know it will be a problem when the month changes. In
> other words what I like to create is a schedule thats
> in a database and loaded according to the week_no.
>
> Any idea on how I can accomplish this.
>
> Your help would be very apreciated.
>
> Thank you.
>
> =====
> "An ounce of gold cannot buy an ounce of time."
> - Anonymous
>
>
> www.whmicro.com
>
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
>
>
>
More information about the talk
mailing list