Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Thanked 9 Times in 9 Posts

    date concatenation problem

    hi friends ,

    I am concatenating the day and month of the year to change the delivery day in case of public holiday

    the code i am using is

    PHP Code:
    $pbDate2 date('d')+$i;
    $pbMon2  date('m');

    $pbDate2 31)
    $pbDate2 $pbDate2 31;
    $pbMon2 $pbMon2 1;
    $pbMon2 >12)
    $pbMon2 $pbMon2-12 ;
    $pbDate2 $pbDate2.$pbMon2

    The problem is e.g

    if my delivery day start fro 28 dec and gos to 3 january and there is holiday on 2 jan

    then pbdate2 variable will return "21"
    2 for day and 1 for month

    The problem occured when date is 1 jan , then month variable is returned as 01 and the variable becomes 201.

    This problem occured yhis year and there are customers who placed orders for 2 januray on 1 january. I check from december month but not on 1 january.

    Any simple solution?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 Posts
    I don't quite understand what you are doing, but once you determine if a holiday exists within a time period, you can simply run an strtotime and add a day to your current timestamp values. This assumes you use a timestamp of course, otherwise you just do some date format and comparisons between the two.
    I assume the idea is that you select items to purchase or whatever, and select a delivery type which has a different time for delivery, say 5 days. If within the 5 day period you have a holiday, it ends up being 6 days, am I right? If so, this idea will work, just determine if a holiday exists (no I don't want to write that up on the fly ), then take your original delivery date and add a +1 on an strtotime to it, should work like a charm (I used that on a project to cheap out on a two week period so I didn't need to error check it off the form).
    PHP Code:
    $newDate strtotime("+1 day"$originalDeliveryDate); 
    is an example of what to do. Check the site for strtotime, there is a link to GNU standards for what the date format in english can look like, there are a lot of options. Frankly, the date() functionality of PHP impresses me far more than most of the other languages that I've used...
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts