php-general Digest 27 Mar 2010 16:50:25 -0000 Issue 6662
php-general Digest 27 Mar 2010 16:50:25 - Issue 6662 Topics (messages 303517 through 303525): Server-side postscript-to-PDF on-the-fly conversion 303517 by: Rob Gould 303518 by: David Robley 303522 by: Floyd Resler 303523 by: Al Re: Please guide in selection of Framework: according to your experience 303519 by: Nilesh Govindarajan 303520 by: Ashley Sheridan Re: Zip and text files generated are corrupted 303521 by: Kim Madsen Noloh PHP Framework 303524 by: Brandon Rampersad is there any setting to declare the member variables in constructor? 303525 by: solo hsi 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 -- ---BeginMessage--- Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. ---End Message--- ---BeginMessage--- Rob Gould wrote: Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. Ghostscript is the first thing that comes to my mind; alternatively googling for convert postscript pdf or similar might turn up other options. Cheers -- David Robley To a cat, NO! means Not while I'm looking. Today is Sweetmorn, the 13rd day of Discord in the YOLD 3176. ---End Message--- ---BeginMessage--- On Mar 27, 2010, at 12:41 AM, Rob Gould gould...@me.com wrote: Is there a free solution out there that will enable me to take a PHP- generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. Is there a particular reason why you need to use Postscript? Can you output it directly to PDF? Take care, Floyd Sent from my iPhone ---End Message--- ---BeginMessage--- On 3/27/2010 12:41 AM, Rob Gould wrote: Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. http://pear.php.net/package/XML_fo2pdf http://pear.php.net/package/File_PDF ---End Message--- ---BeginMessage--- On 03/27/2010 09:58 AM, Vishal Rewari wrote: Dear PHP community, I am vishal, I have
Re: [PHP] Please guide in selection of Framework: according to your experience
On Sat, 2010-03-27 at 11:15 +0530, Nilesh Govindarajan wrote: On 03/27/2010 09:58 AM, Vishal Rewari wrote: Dear PHP community, I am vishal, I have recently started development in PHP I have come across these PHP frameworks: 1. Codeigniter 2. Symphony 3. CakePHP 4. PEAR Please guide me which one of them is *good in performance ? available functionality ? Easy to use and configure* or the one you would recommend according to your experience. My DB is MySQl, or should I stick to native call from PHP? Since you're new to PHP, you should not directly start off with frameworks. I agree, using frameworks makes the job infinite times easier, but as a learning point of view, you should first try to build some applications (not to sell or freelance!) from scratch without using any frameworks. You can of course use minimal PEAR packages. This way you will get a lot to know how to write efficient PHP code. Yes this will take time, but in future you may be one of the best developers coding PHP out there ! Lastly, PEAR isn't a framework, though combining various packages out there you can make one :) First try Zend, its the easiest to use as far I've seen. I have tried Symfony too, but I found it a little tougher to start with. -- Nilesh Govindarajan Site Server Administrator www.itech7.com As far as frameworks go, I've found CodeIgniter very very easy to work with, but I do agree with Nilesh, you should begin by writing code without a framework first. This is because any framework adds an extra layer to your learning, which obviously makes it more difficult for you. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP]Zip and text files generated are corrupted
Mike Roberts wrote on 25/03/2010 14:56: remove No :-) Use the proper unsubscribe method rather than spamming the list. -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server-side postscript-to-PDF on-the-fly conversion
On Mar 27, 2010, at 12:41 AM, Rob Gould gould...@me.com wrote: Is there a free solution out there that will enable me to take a PHP- generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. Is there a particular reason why you need to use Postscript? Can you output it directly to PDF? Take care, Floyd Sent from my iPhone -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Server-side postscript-to-PDF on-the-fly conversion
On 3/27/2010 12:41 AM, Rob Gould wrote: Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. http://pear.php.net/package/XML_fo2pdf http://pear.php.net/package/File_PDF -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Noloh PHP Framework
Hello buds, Anyone have experience with the noloh php framework (noloh) and knows where i can download it? Im not sure if its open source or encrypted. Thanks
[PHP] is there any setting to declare the member variables in constructor?
now i'm re-writing some script to output pdf files. the original code is based on fpdf, but as you know, fpdf can't deal with the characters in utf8. so i want to change it to tcpdf. there is a class extend from fpdf, in its constructor function, there is some script just like $this-db = $db;. there isn't any variable named $db in parent class(class fpdf) and child class, i have checked it carefully and print_r($this) at the top of child's constructor function. but after $this-db=$db, there is a member variable named $db(i have print_r and check it too). when i change the parent class to tcpdf, although i haven't change any code in child class and there isn't a member variable named $db in parent class(class tcpdf), php returns me a error TCPDF ERROR: Cannot access protected property / Undefined property. i print_r($this) at the top of constructor function again and check whether there is a member variable named $db in both parent and child class, finally i'm sure there isn't. i think maybe there is a setting in the parent class(fpdf/tcpdf) here about this condition. it controls whether you can declare a member variable by equaling it. i tried to find it out on google or in fpdf/tcpdf sources but i failed, there are about 16k lines in tcpdf so i post this mail to request some help, is there somebody have any experience about this case? please help me, thanks a lot. solo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Noloh PHP Framework
On Sat, 2010-03-27 at 12:18 -0400, Brandon Rampersad wrote: Hello buds, Anyone have experience with the noloh php framework (noloh) and knows where i can download it? Im not sure if its open source or encrypted. Thanks http://www.google.co.uk/search?q=php+noloh Searching usually helps, and the first result seems to be the main website for the framework ;) Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Server-side postscript-to-PDF on-the-fly conversion
At 12:41 AM -0400 3/27/10, Rob Gould wrote: Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. Rob : Do you want something like this: http://webbytedd.com/bb/pdf/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server-side postscript-to-PDF on-the-fly conversion
On Sat, 2010-03-27 at 12:55 -0400, tedd wrote: At 12:41 AM -0400 3/27/10, Rob Gould wrote: Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. Rob : Do you want something like this: http://webbytedd.com/bb/pdf/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com It doesn't seem to like characters outside the normal range. I tried a name of '©½£¿±®' (cruel parents I know!) and it added a lot of other characters before each one as if it were made up of multibyte characters that it didn't recognise. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Noloh PHP Framework
On Sat, 2010-03-27 at 13:21 -0400, Brandon Rampersad wrote: Thank you but i can't find the download on that website. Anyone have it that can send it to me via an attachment? Thank You On Sat, Mar 27, 2010 at 12:45 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2010-03-27 at 12:18 -0400, Brandon Rampersad wrote: Hello buds, Anyone have experience with the noloh php framework (noloh) and knows where i can download it? Im not sure if its open source or encrypted. Thanks http://www.google.co.uk/search?q=php+noloh Searching usually helps, and the first result seems to be the main website for the framework ;) Thanks, Ash http://www.ashleysheridan.co.uk There's a massive 'Download Now' link that goes to their products page... Ps, you should hit reply to all rather than just reply so that it goes back to the whole list. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Noloh PHP Framework
On Sat, 2010-03-27 at 13:33 -0400, Brandon Rampersad wrote: Sorry, im on gmail and can't find that button. i only see the reply button. maybe try manually adding the php-general email address in? I know a lot of people here use Gmail accounts on the list, maybe one of them knows something that could help you? Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Adding Time
I have a manual input field to add a date on a form. There is another manual input field to add number of months (This is for a loan agreement).I am trying to add the two together to get an ending date. I dont think I am close, can anyone poimt me in the right direction. $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $pay_date = new DateTime($_SESSION['pay_date']); $end_date = new DateTime($_SESSION['pay_date']) + ($_SESSION['loan_length']); echo $end_date-format(m-d.Y).'br /'; date_add($pay_date + new DateInterval($_SESSION['loan_length'])); echo 'br /'.$date-format(d-m-Y); Gary __ Information from ESET NOD32 Antivirus, version of virus signature database 4978 (20100326) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Time
On 03/27/2010 11:13 PM, Gary wrote: I have a manual input field to add a date on a form. There is another manual input field to add number of months (This is for a loan agreement).I am trying to add the two together to get an ending date. I dont think I am close, can anyone poimt me in the right direction. $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $pay_date = new DateTime($_SESSION['pay_date']); $end_date = new DateTime($_SESSION['pay_date']) + ($_SESSION['loan_length']); echo $end_date-format(m-d.Y).'br /'; date_add($pay_date + new DateInterval($_SESSION['loan_length'])); echo 'br /'.$date-format(d-m-Y); Gary __ Information from ESET NOD32 Antivirus, version of virus signature database 4978 (20100326) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com Add time in Unix Timestamps. Then format it using strftime. Also to format inputted date time in the form, check in php manual, to convert dates to timestamps (i forgot the func. name). -- Nilesh Govindarajan Site Server Administrator www.itech7.com मेरा भारत महान ! मम भारत: महत्तम भवतु ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Noloh PHP Framework
Hello Brandon, I'm Asher Snyder, one of the developers of NOLOH. Please feel free to e-mail me with any questions you have. On Sat, Mar 27, 2010 at 1:23 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sat, 2010-03-27 at 13:21 -0400, Brandon Rampersad wrote: Thank you but i can't find the download on that website. Anyone have it that can send it to me via an attachment? Thank You On Sat, Mar 27, 2010 at 12:45 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2010-03-27 at 12:18 -0400, Brandon Rampersad wrote: Hello buds, Anyone have experience with the noloh php framework (noloh) and knows where i can download it? Im not sure if its open source or encrypted. Thanks http://www.google.co.uk/search?q=php+noloh Searching usually helps, and the first result seems to be the main website for the framework ;) Thanks, Ash http://www.ashleysheridan.co.uk There's a massive 'Download Now' link that goes to their products page... Ps, you should hit reply to all rather than just reply so that it goes back to the whole list. Thanks, Ash http://www.ashleysheridan.co.uk -- Asher Snyder Co-founder NOLOH LLC. 347-416-6508 http://www.noloh.com
Re: [PHP] Noloh PHP Framework
I viewed the source on the site like the features suggested I should... does NOLOH always generate HTML with all those hard embedded style attributes? Cheers, Rob. Asher Snyder wrote: Hello Brandon, I'm Asher Snyder, one of the developers of NOLOH. Please feel free to e-mail me with any questions you have. On Sat, Mar 27, 2010 at 1:23 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sat, 2010-03-27 at 13:21 -0400, Brandon Rampersad wrote: Thank you but i can't find the download on that website. Anyone have it that can send it to me via an attachment? Thank You On Sat, Mar 27, 2010 at 12:45 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2010-03-27 at 12:18 -0400, Brandon Rampersad wrote: Hello buds, Anyone have experience with the noloh php framework (noloh) and knows where i can download it? Im not sure if its open source or encrypted. Thanks http://www.google.co.uk/search?q=php+noloh Searching usually helps, and the first result seems to be the main website for the framework ;) Thanks, Ash http://www.ashleysheridan.co.uk There's a massive 'Download Now' link that goes to their products page... Ps, you should hit reply to all rather than just reply so that it goes back to the whole list. Thanks, Ash http://www.ashleysheridan.co.uk -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server-side postscript-to-PDF on-the-fly conversion
On Sat, Mar 27, 2010 at 4:41 AM, Rob Gould gould...@me.com wrote: Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? [...] 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. [...] I think you're looking for a PHP library that can take the output from the function that produces the PS file and generates a PDF file which you then send back to the user. I haven't come across such a utility. I recommend generating a PDF file directly using PDFLib or FPDF ( http://www.fpdf.org/) if possible. An alternative strategy (if you cannot create a PDF directly) could be: 1. Validate input and Generate PS file then go to 2 otherwise raise input exception and exit 2. Write (1) to a temporary location then go to 3 otherwise raise file generation exception and exit 3, Use a utility like ps2pdf (or ghostscript) to convert file to pdf then go to 4 otherwise raise file conversion exception and exit 4. Serve (3) then go to 5 otherwise raise file transfer exception and exit 5. Delete files and exit normally Tutorial on ps2pdf: http://www.linux.com/archive/feed/35022
Re: [PHP] Noloh PHP Framework
On Sat, Mar 27, 2010 at 1:30 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sat, 2010-03-27 at 13:33 -0400, Brandon Rampersad wrote: Sorry, im on gmail and can't find that button. i only see the reply button. maybe try manually adding the php-general email address in? I know a lot of people here use Gmail accounts on the list, maybe one of them knows something that could help you? Thanks, Ash http://www.ashleysheridan.co.uk Brandon, to reply all in gmail, click on the downward arrow right beside the reply button and you'll see the reply all option. Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] Noloh PHP Framework
Hey Rob, No. NOLOH actually generates different code for different devices. For example, a browser with JavaScript will get all elements added via DOM, and no actual HTMLis generated, however when the DOM is viewed via Firebug and properties were explicitly assigned to an object, they're translated as inline styles. All the style attributes are determined by the developer you can either use direct object modification, and/or use CSS classes and style sheets. See http://dev.noloh.com/#/articles/NOLOH-and-CSS/ for more information. There's also some information about layout here: http://dev.noloh.com/#/articles/Layout-in-NOLOH/. If you're interested, we recently came back from 2 weeks ago and posted our very informative and instructive screencast of the talk here: http://vimeo.com/10106797. If this is too long for you, we cut it up into topically concise segments here: http://www.youtube.com/user/phpframework#grid/user/C102458C2FFD8ACF Please let us know if there's anything else you're curious about. Regards, Asher Snyder On Sat, Mar 27, 2010 at 2:19 PM, Robert Cummings rob...@interjinn.comwrote: I viewed the source on the site like the features suggested I should... does NOLOH always generate HTML with all those hard embedded style attributes? Cheers, Rob. Asher Snyder wrote: Hello Brandon, I'm Asher Snyder, one of the developers of NOLOH. Please feel free to e-mail me with any questions you have. On Sat, Mar 27, 2010 at 1:23 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sat, 2010-03-27 at 13:21 -0400, Brandon Rampersad wrote: Thank you but i can't find the download on that website. Anyone have it that can send it to me via an attachment? Thank You On Sat, Mar 27, 2010 at 12:45 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2010-03-27 at 12:18 -0400, Brandon Rampersad wrote: Hello buds, Anyone have experience with the noloh php framework (noloh) and knows where i can download it? Im not sure if its open source or encrypted. Thanks http://www.google.co.uk/search?q=php+noloh Searching usually helps, and the first result seems to be the main website for the framework ;) Thanks, Ash http://www.ashleysheridan.co.uk There's a massive 'Download Now' link that goes to their products page... Ps, you should hit reply to all rather than just reply so that it goes back to the whole list. Thanks, Ash http://www.ashleysheridan.co.uk -- http://www.interjinn.com Application and Templating Framework for PHP -- Asher Snyder Co-founder NOLOH LLC. 347-416-6508 http://www.noloh.com
Re: [PHP] Server-side postscript-to-PDF on-the-fly conversion
27 mar 2010 kl. 05.41 skrev Rob Gould: Is there a free solution out there that will enable me to take a PHP- generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link? More description of what I'm trying to do: 1) I've got a web-page that accepts some user input 2) They hit SUBMIT 3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview. 4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed. If your webserver runs on MacOSX, look out for a binary called 'pstopdf'. From the man page: [...] pstopdf is a tool to convert PostScript input data into a PDF document. The input data may come from a file or may be read from stdin. The PDF document is always written to a file. The name of the output PDF file is derived from the name of the input file or may be explicitly named using the -o option. [...] Another option might be xpdf (http://www.foolabs.com/xpdf/). There are several different tools bundled with that app and there might be some ps - pdf converter too. Otherwise, there is always Ghostscript. /frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Time
Thanks for your reply. This comes from the manual, I have tried to change to my variables. I am not getting any error messages, but I am not able to add the $loan_length to the $pay_date. Thanks again for any help. gary ?php $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $orgDate=($_SESSION['pay_date']); $mth=($_SESSION['loan_length']); function add_date($orgDate,$mth){ $cd = strtotime($orgDate); $end_date = date('Y-m-d', mktime(0,0,0,date('m',$cd)+$mth,date('d',$cd),date('Y',$cd))); return $end_date; } echo $orgDate .br /; echo $end_date .br /; echo $pay_date .br /; echo $loan_length; ? Nilesh Govindarajan li...@itech7.com wrote in message news:4bae4578.9080...@itech7.com... On 03/27/2010 11:13 PM, Gary wrote: I have a manual input field to add a date on a form. There is another manual input field to add number of months (This is for a loan agreement).I am trying to add the two together to get an ending date. I dont think I am close, can anyone poimt me in the right direction. $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $pay_date = new DateTime($_SESSION['pay_date']); $end_date = new DateTime($_SESSION['pay_date']) + ($_SESSION['loan_length']); echo $end_date-format(m-d.Y).'br /'; date_add($pay_date + new DateInterval($_SESSION['loan_length'])); echo 'br /'.$date-format(d-m-Y); Gary __ Information from ESET NOD32 Antivirus, version of virus signature database 4978 (20100326) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com Add time in Unix Timestamps. Then format it using strftime. Also to format inputted date time in the form, check in php manual, to convert dates to timestamps (i forgot the func. name). -- Nilesh Govindarajan Site Server Administrator www.itech7.com ! ?? : ?? ! __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Time
On Sat, Mar 27, 2010 at 8:41 PM, Gary gwp...@ptd.net wrote: [...] ?php $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $orgDate=($_SESSION['pay_date']); $mth=($_SESSION['loan_length']); function add_date($orgDate,$mth){ $cd = strtotime($orgDate); $end_date = date('Y-m-d', mktime(0,0,0,date('m',$cd)+$mth,date('d',$cd),date('Y',$cd))); return $end_date; } echo $orgDate .br /; echo $end_date .br /; echo $pay_date .br /; echo $loan_length; ? You access form element values via the $_POST superglobal, why are you using $_SESSION? http://php.net/manual/en/reserved.variables.post.php
Re: [PHP] Adding Time
It is a multi page form with all information being writting to the database via the $_SESSION's. Gary Yousif Masoud yousif.mas...@gmail.com wrote in message news:k2qbffe24ad1003271414za1377a2dsb0e4a2d23d411...@mail.gmail.com... On Sat, Mar 27, 2010 at 8:41 PM, Gary gwp...@ptd.net wrote: [...] ?php $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $orgDate=($_SESSION['pay_date']); $mth=($_SESSION['loan_length']); function add_date($orgDate,$mth){ $cd = strtotime($orgDate); $end_date = date('Y-m-d', mktime(0,0,0,date('m',$cd)+$mth,date('d',$cd),date('Y',$cd))); return $end_date; } echo $orgDate .br /; echo $end_date .br /; echo $pay_date .br /; echo $loan_length; ? You access form element values via the $_POST superglobal, why are you using $_SESSION? http://php.net/manual/en/reserved.variables.post.php __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Time
On Sat, Mar 27, 2010 at 8:41 PM, Gary gwp...@ptd.net wrote: [...] ?php $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $orgDate=($_SESSION['pay_date']); $mth=($_SESSION['loan_length']); function add_date($orgDate,$mth){ $cd = strtotime($orgDate); $end_date = date('Y-m-d', mktime(0,0,0,date('m',$cd)+$mth,date('d',$cd),date('Y',$cd))); return $end_date; } echo $orgDate .br /; echo $end_date .br /; echo $pay_date .br /; echo $loan_length; ? Can you echo $pay_date and show us how the input date is formatted? eg. 2010-03-27 Can you also show us the output of the last four echo statements? This works for me: function addMonthsToDate($start,$month) { return strtotime($start + $month months); } $test = addMonthsToDate(2010-03-26,3); echo date('Y-m-d',$test); // gives 2010-06-26
Re: [PHP] Adding Time
I have copied the echo and the code, for clarity I have echo'd 1,2,3, etc to see which is working. Thank you for your help. Hope this is clear. Gary $loan_length=($_SESSION['loan_length']); //is set to 36 months $pay_date=($_SESSION['pay_date']); //is set to 01-05-2010 $orgDate=($_SESSION['pay_date']); $mth=($_SESSION['loan_length']); $end_date=date('m-d-Y',strtotime('$mth')) + date('m-d-Y', strtotime('$pay_date')); $loan_length=date('m-d-Y'); $mthdate=date('m-d-Y', function add_date($orgDate,$mth){ $cd = strtotime($orgDate); return $end_date; } $orgDate=date(m,strtotime('$loan_length')); echo 1 .br /; echo $mth .br /; echo 2 .br /; echo $end_date .br /; echo 3 .br /; echo $pay_date .br /; echo 4 .br /; echo $loan_length.br /; echo 5 .br /; echo $orgDate.br /; ? ***Page output*** 1 36 //this is correct 2 24 //this is not 3 01-05-2010 4 03-27-2010 5 12 //this is not Yousif Masoud yousif.mas...@gmail.com wrote in message news:x2sbffe24ad1003271508xb1f414fck7b6eb93a6cd79...@mail.gmail.com... On Sat, Mar 27, 2010 at 8:41 PM, Gary gwp...@ptd.net wrote: [...] ?php $pay_date=($_SESSION['pay_date']); $loan_length=($_SESSION['loan_length']); $orgDate=($_SESSION['pay_date']); $mth=($_SESSION['loan_length']); function add_date($orgDate,$mth){ $cd = strtotime($orgDate); $end_date = date('Y-m-d', mktime(0,0,0,date('m',$cd)+$mth,date('d',$cd),date('Y',$cd))); return $end_date; } echo $orgDate .br /; echo $end_date .br /; echo $pay_date .br /; echo $loan_length; ? Can you echo $pay_date and show us how the input date is formatted? eg. 2010-03-27 Can you also show us the output of the last four echo statements? This works for me: function addMonthsToDate($start,$month) { return strtotime($start + $month months); } $test = addMonthsToDate(2010-03-26,3); echo date('Y-m-d',$test); // gives 2010-06-26 __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Time
On Sat, Mar 27, 2010 at 10:26 PM, Gary gwp...@ptd.net wrote: [...] strtotime('$pay_date')); [...] If you want the value of $pay_date to be the argument of strtotime, you need to enclose it in double quotes (do the same for all other occurrences). Try: strtotime($pay_date); [...] When a string http://www.php.net/manual/en/language.types.string.php is specified in double quotes or with heredoc, variableshttp://www.php.net/manual/en/language.variables.phpare parsed within it. [...] from: http://php.net/manual/en/language.types.string.php Beginning of Variable Parsing Section
Re: [PHP] Adding Time
On Sat, Mar 27, 2010 at 10:26 PM, Gary gwp...@ptd.net wrote: [...] $end_date=date('m-d-Y',strtotime('$mth')) + date('m-d-Y', strtotime('$pay_date')); [...] Try changing above to: $end_date = date('m-d-Y',strtotime($pay_date + $mth months)); I think your mail client took it out of the add_date function.
Re: [PHP] Adding Time
Perfect, thank you very much for your help! Gary Yousif Masoud yousif.mas...@gmail.com wrote in message news:x2tbffe24ad1003271548l65cb6e65qd8f35ae0636e...@mail.gmail.com... On Sat, Mar 27, 2010 at 10:26 PM, Gary gwp...@ptd.net wrote: [...] $end_date=date('m-d-Y',strtotime('$mth')) + date('m-d-Y', strtotime('$pay_date')); [...] Try changing above to: $end_date = date('m-d-Y',strtotime($pay_date + $mth months)); I think your mail client took it out of the add_date function. __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php