Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calculate Day (as in Monday or Tuesday etc) from Date

    Calculate Day (as in Monday or Tuesday etc) from Date

    I have a value in a textbox (date) ex: 04/22/2013 2:51:00 PM
    Can I calculate from this value the day of the week?
    Any examples?
    Thanks

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Code:
    <input type = "text" id = "mydate" value = "04/22/2013 2:51:00 PM">
    
    <script type = "text/javascript">
    
    var dys = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
    var d = document.getElementById("mydate").value;
    var day = new Date(d).getDay();  // days are 0 Sunday - 6 Saturday
    alert (dys[day]);  // Monday
    
    </script>

    de Resta [British racing driver] had problems with overheating nuts. - Commentator BBC 1
    Last edited by Philip M; 04-22-2013 at 09:50 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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