Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Returning the date 2days from today

Posted on 2003-02-19
Medium Priority
Last Modified: 2013-12-25
Ok here is my question, is there an easy way to return the next day to the current one ?

For example,I have an order form, where the user specifies the delivery date, via dd / mm / yyyy, but I want to do a simple check and prompt them if the day is before 2days after the current date.

The difficaulty is of course when they get to the end of the month.

Is there an easy way round this or is it a case of many many if statments.


Scott WRight
Question by:scottwright
  • 2

Expert Comment

ID: 7980986
are you using perl?

Accepted Solution

markhoy earned 300 total points
ID: 7980992
try this..

you can as well convert this program into a sub-routine and use it wherever you want.

Hope that helps.



($sec, $min, $hour, $day, $mon, $year, $wday, $yday) = localtime (time);
$y2kyear = $year+1900;
##  Pad the month and the day with a 0
$date = sprintf("%02d",$mon).'/'.sprintf("%02d",$day).'/'.$y2kyear;
print "Current Date is $date\n";

$future = time + ($days_ahead*24*60*60);

($sec, $min, $hour, $day, $mon, $year, $wday, $yday) = localtime ($future);
$y2kyear = $year+1900;
$date = sprintf("%02d",$mon).'/'.sprintf("%02d",$day).'/'.$y2kyear;
print "$days_ahead days later the date will be $date\n";

see: http://www.experts-exchange.com/Web/Web_Languages/CGI/Q_11811379.html

or look in the Perl Cookbook (Camel)..

Author Comment

ID: 7981137
excellent worked pefect! thanks heaps

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

575 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question