Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Brian Andersen 35 posts 66 karma points
    Dec 05, 2010 @ 19:54
    Brian Andersen
    0

    Getting the current date

    How do i get te current server  date in XSLT.

     

    I tried:

     

    <xsl:value-of select="umbraco.library:FormatDateTime(Exslt.ExsltDatesAndTimes:date(), 'dd/mm/yy')" />

     

    But it returns 30/11/2010 and not 05/12/2010 as i would expect. Any good ideas? 

    Thanks!
    Brian

  • Rich Green 2246 posts 4008 karma points
    Dec 05, 2010 @ 19:59
    Rich Green
    1

    Hi Brian,

    You can use the following to get the current date

    umbraco.library:CurrentDate()

    Rich

  • Brian Andersen 35 posts 66 karma points
    Dec 05, 2010 @ 20:11
    Brian Andersen
    0

    i Rich

    Ok, tanks alot. I keep getting weird dates though but it must be some other part of this jquery picker i'm working with. This:


    <xsl:value-of select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'mm/dd/yy')" />

    Returns random dates. Now it says: 19/11/2010

    /Brian


  • Brian Andersen 35 posts 66 karma points
    Dec 05, 2010 @ 20:19
    Brian Andersen
    0

    umbraco.library:FormatDateTime()

    Works fine. The error is here:

    umbraco.library:FormatDateTime()

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 05, 2010 @ 20:24
    Jan Skovgaard
    0

    I think that the extension is using the time on the server so maybe it's because it's date is out of sync you are getting the wrong date?

    /Jan

  • Brian Andersen 35 posts 66 karma points
    Dec 05, 2010 @ 20:38
    Brian Andersen
    0

    I get the right time when i output umbraco.library:CurrentDate():

    2010-12-05T20:30:27

    I am using the xslt inside this:
    <xsl:value-of select="umbraco.library:AddJquery()"/>

        <script type="text/javascript">

    That may be the problem I am not sure yet. The reason my initial code was changing was because i used minutes ->  "dd/mm/yy" /Brian

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 05, 2010 @ 20:42
    Jan Skovgaard
    0

    Hi Brian

    It seems like some of the code you're trying to paste is missing? I can't see the full <script> code?

    /Jan

  • Brian Andersen 35 posts 66 karma points
    Dec 05, 2010 @ 20:48
    Brian Andersen
    0

    Here is the code if you wan't a look:

    <xsl:template match="/">
    
        <xsl:value-of select="umbraco.library:AddJquery()"/>
        <script type="text/javascript">
    
            $(function () {
    
            $('#check').bind('click', function () {
    
    
            var arr = $('#arriving').val();
            var arrUrl = arr.split("/");
            var UrlArrDone = arrUrl[1] + '.' + arrUrl[0] + '.' + arrUrl[2];
    
            var dep = $('#departing').val();
            var depUrl = dep.split("/");
            var UrldepDone = depUrl[1] + '.' + depUrl[0] + '.' + depUrl[2];
    
    
    
    
    
    
            window.open("<xsl:value-of select="$currentPage/bookingUrl" disable-output-escaping="yes" />" +
            "<xsl:text disable-output-escaping="yes">&#38;depart=</xsl:text>"
            + UrldepDone +
            "<xsl:text disable-output-escaping="yes">&#38;arrive=</xsl:text>"
            + UrlArrDone +
            "<xsl:text disable-output-escaping="yes">&#38;adult=</xsl:text>"
            + $('#adults').val() +
            "<xsl:text disable-output-escaping="yes">&#38;child=</xsl:text>"
            + $('#children').val() +
            "<xsl:text disable-output-escaping="yes">&#38;promo=</xsl:text>"
            + $('#promocode').val() +
            "<xsl:text disable-output-escaping="yes">&#38;rooms=</xsl:text>"
            + $('#rooms').val()
    
            );
            return false;
            });
            });
    
    
            $(function () {
            // Datepicker
            $(function () {
            $("#arriving").datepicker(
            {
            dateFormat: 'dd/mm/yy',
            altField: '#arrival',
            altFormat: 'yy/mm/dd',
            onSelect: function (dateText, inst) {
            }
            }
            );
            $("#arriving").datepicker('setDate', '<xsl:value-of select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'dd/MM/yyyy')" />');
        inline: true
        });
        $(function () {
        $("#departing").datepicker(
        {
        dateFormat: 'dd/mm/yy',
        altField: '#departure',
        altFormat: 'yy/mm/dd'
        }
        );
        $("#departing").datepicker('setDate', '<xsl:value-of select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'dd/MM/yyyy')" />');
        inline: true
        });
        });
    
    
    </script>
    </xsl:template>

Please Sign in or register to post replies

Write your reply to:

Draft