Code to Display Indian Time in PHP When you have clients in India, you definitely will need this at one time or another to display Indian Time on the pages published using the perfect CMS that you have built. This small snippet explains how to get Indian Time in PHP without changing the server times and timezones. So irrespective of whether your server is in PST or GMT, you can still display IST when displaying this with PHP. <?php $timezone = new DateTimeZone("Asia/Kolkata" ); $date = new DateTime(); $date->setTimezone($timezone ); echo $date->format( 'H:i:s A / D, M jS, Y' ); ?> Here is a list of supported timezones in ...
» continue readingThis is something easy but I see you are here because you need to know how to do this. So here is the code that can help you with Rounding Off Numbers using Javascript. Nice and Easy!! <script language="javascript"> function formatNumber(myNum, numOfDec) { var decimal = 1 for(i=1; i<=numOfDec;i++) decimal = decimal *10 var myFormattedNum = (Math.round(myNum * decimal)/decimal).toFixed(numOfDec) return(myFormattedNum) } </script> To call this function, use Alert(formatNumber(23244.4325, 2))
» continue readingI have seen many programmers searching for unescape in PHP and there is no such function by this name in PHP. There is a function that does the same job in php and its called stripslashes which unescapes the special characters using server side processing.
» continue readingIts really easy code and nothing complicated here. All of us add a copyright information to the footers of the websites that we do and also add current year. Later on our clients call up and ask us to change this to current year again. So this simple code comes handy to display the current year as per the server's time zone. If you use PHP Programming you can use <?php echo date("Y") ?> If you use ASP Programming <%=Year(Date)%> Happy Coding!!
» continue reading