SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    May 2005
    Posts
    297
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to check if date given is a sunday

    I am getting a date from the user in the dd/mm/yyyy format, how would I be able to check if this date happens to be a Sunday?

    Thanks

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $inputDate 
    $_POST['date'];
    $inputDateArray explode('/'$inputDate);
    if(
    date('N'mktime (00$inputDateArray[1], $inputDateArray[0], $inputDateArray[2])) == 7){
        
    //Date is a Sunday
    }
    That will also work with the date being in dd/mm/yy too.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

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