SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to convert unixtimestamp to date using php function

    Hi

    how to convert unixtimestamp to date using php functions.help to solve this problem

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,095
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    PHP Code:
    echo date('Y-m-d H:i:s'$myTimestamp); 
    date

    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hi

    i store the multicheckbox values as a sumofarray in database, i want to compare the values with original and set as checked , how do it can any one help me to solve the problem


    for example
    PHP Code:
    <input type="checkbox" value="1" name="val[]">
    <
    input type="checkbox" value="2" name="val[]">
    <
    input type="checkbox" value="4" name="val[]">
    <
    input type="checkbox" value="8" name="val[]"

  4. #4
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    PHP Code:
    echo date('Y-m-d H:i:s'$myTimestamp); 
    date

    thank u

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    /*
      Defaults
    */
    $checkboxes = array(
      
    => false,
      
    => false,
      
    => false,
      
    => false,
      
    => false
    );

    /*
      Values from database
    */
    $database = array(
      
    => true,
      
    => true,
    );

    foreach(
    array_replace($checkboxes$database) as $value => $isChecked){
      
    printf(
        
    '<input type="checkbox" name="val[]" value="%s" %s />' PHP_EOL,
        
    $value,
        
    $isChecked 'checked="checked"' ''
      
    );
    }

    /*
      <input type="checkbox" name="val[]" value="1"  />
      <input type="checkbox" name="val[]" value="2" checked="checked" />
      <input type="checkbox" name="val[]" value="3"  />
      <input type="checkbox" name="val[]" value="4" checked="checked" />
      <input type="checkbox" name="val[]" value="5"  />
    */
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i m storing checkbox array values as sum in database
    if first and second checkbox check i m storing the values as sum of array

    array_sum(checkbox array) in database

    now values from database is 2+4 =6

    how to decode and set check box as checked status

  7. #7
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    See my answer in your other thread.

    http://www.sitepoint.com/forums/php-...ml#post4917965

    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •