CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • Convert PHP to ASP Classic - Special Characters pt.1 (Facebook Comment Time Sent)

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    125
  • Date Created
    Monday, March 28, 2011
  • Last Updated
    Monday, March 28, 2011
  • This Article Has been Viewed
    2566 times
  • Short Desc
    The articles here are to help people convert PHP scripting language over to ASP Classic.
  • Details
    This article will focus on the different Characters that PHP uses and what the equivalent is in ASP Classic and how to re-write the code to work in your ASP Classic projects.

    Be sure to look at the bottom for the Related articles, so you can continue in these lessons on learning the process.
  • Recreate Issue
    To recreate the issue:

    <?php
    $days2 = floor($rows['CommentTimeSpent'] / (60 * 60 * 24));
    $remainder = $rows['CommentTimeSpent'] % (60 * 60 * 24);
    $hours = floor($remainder / (60 * 60));
    $remainder = $remainder % (60 * 60);
    $minutes = floor($remainder / 60);
    $seconds = $remainder % 60;
    ?>


    This code will take a date and match it to the timestamp it was presented to the database.
    This code is similar to what Facebook uses on the member left comments.

    First lets look at what the code is doing.

    #1: The opening and closing Brackets in PHP
    <?php
    // Your data information goes here
    ?>


    #2: php $
    This represents a Variable, so if you have
    $days2
    Then you will be able to use the days2 within your code, as you have created a value for it here: $days2 = floor($rows['CommentTimeSpent'] / (60 * 60 * 24));
    So this gets the Value and displays its information to the page.

    #3: php %
    This is a modulus function

    #4: floor()
    This will convert decimal to an integer value.
  • Resolve Issue
    To resolve this issue:
    Converting the PHP to ASP Classic


    <%

    dim days2
    dim remainder
    dim hours
    dim minutes
    dim seconds
    days2 = int(rsProCom("timestamp") / (60 * 60 * 24))
    remainder = rsProCom("timestamp") mod (60 * 60 * 24)
    hours = int(remainder / (60 * 60))
    remainder = remainder mod (60 * 60)
    minutes = int(remainder / (60))
    seconds = remainder mod (60)
    %>

    (We have not implemented the PHP FLOOR function in this example, sorry)


    #1: The opening and closing Brackets in ASP

    <%
    ' Your data information goes here
    %>


    #2: ASP DIM
    The DIM is used to set a Variable to be used, ASP Classic uses the DIM instead of the PHP $

    #3: ASP mod
    This is a modulus function

    #4: int()
    This is the equivalent of the floor() values, of which converts decimal to an integer value.


    --------
    Related Articles
    Convert PHP to ASP Classic - Special Characters pt.2 (Facebook Comment Time Sent)«