Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
How to determine the weekday of a given date?

How to display weekday (monday to sunday) of the entered date of birth? This code will display the Years, Months, Days (in number) and I am trying to find how to display the weekday but failed so many times and got frustrated.

<!DOCTYPE HTML>
<html>
    <head>
        <title>Age calculator</title>
        <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
        <link rel="stylesheet" href="https://formden.com/static/cdn/bootstrap-iso.css"/>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/> 
    </head>
    </head>
    <body>
        <?php
            error_reporting(0);
            if(isset($_POST['submit'])){
                $dateOfBirth = $_POST['dateOfBirth'];
                $today = date("Y-m-d");
                $diff = date_diff(date_create($dateOfBirth),date_create( $today));
                $output= $diff->format('%y Years, %m Months, %d Days'); 
            } 
        ?>
        <form method="post" action="">
            <input type="text" name="dateOfBirth" id="dob" />
            <input type="submit" value="submit" name="submit" /><br>
            <?php
                echo $output;
            ?>
        </form>

        <script>
            $(document).ready(function(){
              var date_input=$('input[name="dateOfBirth"]'); //our date input has the name "date"
              var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
              var options={
                format: 'mm/dd/yyyy',
                container: container,
                todayHighlight: true,
                autoclose: true,
                orientation: "top left",
              };
              date_input.datepicker(options);
            })

            function show_now(){
                var my_day=new Date(dob)
                //var dt = new Date(\"Aug 16, 2005 05:55:00\");
                var day_name=new Array(7);
                day_name[0]='Sunday'
                day_name[1]=' Monday'
                day_name[2]='Tuesday'
                day_name[3]='Wednesday'
                day_name[4]='Thursday'
                day_name[5]='Friday'
                day_name[6]='Saturday'

                alert ("Today Day is  = " + day_name[my_day.getDay(dob)]); 
            }
        </script>
    <body>
        <input type=button value="Show Day" onclick="show_now();">
    </script>
    </body>
</html> 
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can display the day of week with the date function and the format option 'w'.

$dayOfWeek = date('w', strtotime($bDayDate));

For more information see w3school date function.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!