?
Solved

Returning the date 2days from today

Posted on 2003-02-19
3
Medium Priority
?
162 Views
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.

Regards

Scott WRight
0
Comment
Question by:scottwright
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:markhoy
ID: 7980986
are you using perl?
0
 
LVL 7

Accepted Solution

by:
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.

#!/usr/local/bin/perl

$days_ahead=2;

($sec, $min, $hour, $day, $mon, $year, $wday, $yday) = localtime (time);
$mon++;
$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);
$mon++;
$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)..
0
 

Author Comment

by:scottwright
ID: 7981137
excellent worked pefect! thanks heaps
0

Featured Post

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

777 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