php-general Digest 1 Dec 2011 21:20:28 -0000 Issue 7594
Topics (messages 315914 through 315918):
Introducing Onion - Another PHP packager
315914 by: Lin Yo-An
Re: compare dates
315915 by: Maciek Sokolewicz
315916 by: Maciek Sokolewicz
315917 by: Maciek Sokolewicz
315918 by: Marc Fromm
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Hi All,
I'm currently working on a PEAR packager, which uses a very simple config
file to generate PEAR package (package.xml 2.0 compatible mostly). It
started from an internal use of our company, but we'd like to open source.
It's called Onion.
Onion provides a standalone phar file to build package from package.ini
file, to build a basic package, what you only need is 5 lines:
[package]
name = package name
desc = package description
version = 0.0.1
author = Author Name <email@email>
stability, channel, dependency, roles, contents are also able to be
specified.
Here is some demo and screenshot:
http://c9s.blogspot.com/2011/12/php-current-onion-php-package-builder.html
This project is hosted on GitHub:
https://github.com/c9s/Onion
And our pear channel
http://pear.corneltek.com/
Hope you will like it.
Thanks
Best Regards,
Yo-An Lin (c9s)
--- End Message ---
--- Begin Message ---
On 01-12-2011 02:17, Floyd Resler wrote:
On Nov 30, 2011, at 5:04 PM, Matijn Woudt wrote:
On Wed, Nov 30, 2011 at 11:00 PM, Marc Fromm<marc.fr...@wwu.edu> wrote:
I'm puzzled why the if statement executes as true when the first date
(job_closedate) is not less than the second date (now).
The if statement claims that "12/02/2011" is less than "11/30/2011".
if (date("m/d/Y",strtotime($jobs_closedate))<=
date("m/d/Y",strtotime("now"))){
You're comparing strings here, try to compare the unix timestamp:
if (strtotime($jobs_closedate)<= strtotime("now")){
That'll probably do what you want..
Matijn
Another way to do it would be:
if(strtotime($jobs_closedate)<=time()) {
}
or
if(date("Y-m-d",strtotime($job_closedate))<=date("Y-m-d",time()) {
}
Take care,
Floyd
As of PHP 5.2.2 direct comparison of DateTime objects is also possible. So:
$closeDate = new DateTime($jobs_closedate);
$now = new DateTime('now');
if($closeDate < $now) {
echo $closeDate->format('m/d/Y'); // output in US date format
echo $now->format('m/d/Y'); // output in US date format
$error .= "The close date must be later than today's date, " .
$now->format('m/d/Y') . "\n";
}
This, IMO is a lot prettier.
- Tul
--- End Message ---
--- Begin Message ---
On 01-12-2011 02:17, Floyd Resler wrote:
On Nov 30, 2011, at 5:04 PM, Matijn Woudt wrote:
On Wed, Nov 30, 2011 at 11:00 PM, Marc Fromm<marc.fr...@wwu.edu> wrote:
I'm puzzled why the if statement executes as true when the first date
(job_closedate) is not less than the second date (now).
The if statement claims that "12/02/2011" is less than "11/30/2011".
if (date("m/d/Y",strtotime($jobs_closedate))<=
date("m/d/Y",strtotime("now"))){
You're comparing strings here, try to compare the unix timestamp:
if (strtotime($jobs_closedate)<= strtotime("now")){
That'll probably do what you want..
Matijn
Another way to do it would be:
if(strtotime($jobs_closedate)<=time()) {
}
or
if(date("Y-m-d",strtotime($job_closedate))<=date("Y-m-d",time()) {
}
Take care,
Floyd
As of PHP 5.2.2 direct comparison of DateTime objects is also possible. So:
$closeDate = new DateTime($jobs_closedate);
$now = new DateTime('now');
if($closeDate < $now) {
echo $closeDate->format('m/d/Y'); // output in US date format
echo $now->format('m/d/Y'); // output in US date format
$error .= "The close date must be later than today's date, " .
$now->format('m/d/Y') . "\n";
}
This, IMO is a lot prettier.
- Tul
--- End Message ---
--- Begin Message ---
On 01-12-2011 02:17, Floyd Resler wrote:
On Nov 30, 2011, at 5:04 PM, Matijn Woudt wrote:
On Wed, Nov 30, 2011 at 11:00 PM, Marc Fromm<marc.fr...@wwu.edu> wrote:
I'm puzzled why the if statement executes as true when the first date
(job_closedate) is not less than the second date (now).
The if statement claims that "12/02/2011" is less than "11/30/2011".
if (date("m/d/Y",strtotime($jobs_closedate))<=
date("m/d/Y",strtotime("now"))){
You're comparing strings here, try to compare the unix timestamp:
if (strtotime($jobs_closedate)<= strtotime("now")){
That'll probably do what you want..
Matijn
Another way to do it would be:
if(strtotime($jobs_closedate)<=time()) {
}
or
if(date("Y-m-d",strtotime($job_closedate))<=date("Y-m-d",time()) {
}
Take care,
Floyd
As of PHP 5.2.2 direct comparison of DateTime objects is also possible. So:
$closeDate = new DateTime($jobs_closedate);
$now = new DateTime('now');
if($closeDate < $now) {
echo $closeDate->format('m/d/Y'); // output in US date format
echo $now->format('m/d/Y'); // output in US date format
$error .= "The close date must be later than today's date, " .
$now->format('m/d/Y') . "\n";
}
This, IMO is a lot prettier.
- Tul
--- End Message ---
--- Begin Message ---
Thanks. I'm stuck using 5.1.6. Matijn reply worked by using the unix timestamp.
-----Original Message-----
From: Maciek Sokolewicz [mailto:tula...@gmail.com] On Behalf Of Maciek
Sokolewicz
Sent: Thursday, December 01, 2011 12:57 PM
To: Marc Fromm
Cc: Floyd Resler
Subject: Re: [PHP] compare dates
On 01-12-2011 02:17, Floyd Resler wrote:
>
> On Nov 30, 2011, at 5:04 PM, Matijn Woudt wrote:
>
>> On Wed, Nov 30, 2011 at 11:00 PM, Marc Fromm<marc.fr...@wwu.edu> wrote:
>>> I'm puzzled why the if statement executes as true when the first date
>>> (job_closedate) is not less than the second date (now).
>>> The if statement claims that "12/02/2011" is less than "11/30/2011".
>>>
>>> if (date("m/d/Y",strtotime($jobs_closedate))<=
>>> date("m/d/Y",strtotime("now"))){
>>
>> You're comparing strings here, try to compare the unix timestamp:
>>
>> if (strtotime($jobs_closedate)<= strtotime("now")){
>>
>> That'll probably do what you want..
>>
>> Matijn
>>
>
> Another way to do it would be:
> if(strtotime($jobs_closedate)<=time()) { }
>
> or
>
> if(date("Y-m-d",strtotime($job_closedate))<=date("Y-m-d",time()) { }
>
> Take care,
> Floyd
As of PHP 5.2.2 direct comparison of DateTime objects is also possible. So:
$closeDate = new DateTime($jobs_closedate); $now = new DateTime('now');
if($closeDate < $now) {
echo $closeDate->format('m/d/Y'); // output in US date format
echo $now->format('m/d/Y'); // output in US date format
$error .= "The close date must be later than today's date, " .
$now->format('m/d/Y') . "\n";
}
This, IMO is a lot prettier.
- Tul
--- End Message ---