Menus

Thursday 25 July 2019

how to get the number of days of the current month in PHP ?




cal_days_in_month — Return the number of days in a month for a given year and calendar

Description 

cal_days_in_month ( int $calendar , int $month , int $year ) : int
This function will return the number of days in the month of year for the specified calendar.
The length in days of the selected month in the given calendar

More details


example

             $m1=date('Y-m-d',strtotime($date_of_join));            
           
             $mon_num = date("m",strtotime($m1));
             $curr_year = date("Y",strtotime($m1));

            $num = cal_days_in_month(CAL_GREGORIAN, $mon_num, $curr_year);



PHP code for find number of days form given month and year ?



<?php

$month = 2;
$year = 2020;

$days = $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);

echo $days;

?>




Monday 1 July 2019

Android Scrolling text in Textview


Android auto scrolling text

This tutorial explain to scroll text message on activity.

How to make Marquee text in Android?


Property as marquee
android:ellipsize = "marquee"
android:fadingEdge = "horizontal"
android:marqueeRepeatLimit = "marquee_forever"
android:scrollHorizontally = "true"
android:singleLine = "true"






Add the following code to res/layout/activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.root.scrolling.MainActivity">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            >



                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Hello World!" />

                <TextView
                    android:id="@+id/txtScroll"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textSize="30dp"
                    android:background="#D0D0D0"
                    android:text="http://yii2ideas.blogspot.com/"

                    android:focusable="true"

                    android:focusableInTouchMode="true"
                    android:singleLine="true"
                    android:scrollHorizontally="true"
                    android:ellipsize="marquee"
                    android:marqueeRepeatLimit="marquee_forever"
                    />
             
        </LinearLayout>
     
</RelativeLayout>




Useful Links
Android Drop Down List Tutorial

Android date picker dialog