locked
trying to get a string date from a asp.net label time RRS feed

  • Question

  • User-431147622 posted

    hello ASPians,

    I have a label which is loading my time format as Format(Now, "MMM d, yyyy" + " " + "h:mm:ss") in my asp.net web form

    now i am trying to get the value of the label to pass it to a javascript 

    var gettimedatevalue = document.getElementById("<%=lbltimeformat.ClientID%>").innerHTML;

    <script>

    var gettimedatevalue = "Jan 5 2021 15:37:25"; ----------> i insert this string date to test and it works perfect but when i am trying to get the value from the lbltimeformat its not getting the value
    var countDownDate = new Date(gettimedatevalue);
    window.alert(gettimedatevalue)

    </script>

    any help would be appreciate

    Sunday, January 26, 2020 4:52 AM

All replies

  • User-431147622 posted

    i manage to get it work, it took me long time but yeah i was getting addict to it...

    hope it helps someone who has a server side time in asp.net to be retrieve in javascript ...

    var countDownDate = new Date(Date.parse(document.getElementById("lbltimeformat").innerHTML));

    Sunday, January 26, 2020 6:52 AM