take minutes only from the time format in php before the record update





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















$aak is show 00:17:00 and i just want get 17



$aak=$data2["jamwaktukerja"];


i use this code for get minute,but still wrong



$time = date("i ", $aak);

var_dump($time);


$masuk2 = 'UPDATE presensi SET menitwaktukerja ="'.$time.'" where
tanggal="'.$cellValueB.'" and nip="'.$data1["nip"].'" ';
$query4 = mysqli_query($con,$masuk2);









share|improve this question

























  • you need to provide date with a valid timestamp as second parameter. 00:17:00 is not a timestamp yet.You can use strtotime() for that.

    – Jeff
    Nov 27 '18 at 1:22








  • 1





    If you are 100% sure, that the input is always in this format you could $time = explode(':', $aak) and you'll have the minutes in $time[1].

    – Jeff
    Nov 27 '18 at 1:24


















0















$aak is show 00:17:00 and i just want get 17



$aak=$data2["jamwaktukerja"];


i use this code for get minute,but still wrong



$time = date("i ", $aak);

var_dump($time);


$masuk2 = 'UPDATE presensi SET menitwaktukerja ="'.$time.'" where
tanggal="'.$cellValueB.'" and nip="'.$data1["nip"].'" ';
$query4 = mysqli_query($con,$masuk2);









share|improve this question

























  • you need to provide date with a valid timestamp as second parameter. 00:17:00 is not a timestamp yet.You can use strtotime() for that.

    – Jeff
    Nov 27 '18 at 1:22








  • 1





    If you are 100% sure, that the input is always in this format you could $time = explode(':', $aak) and you'll have the minutes in $time[1].

    – Jeff
    Nov 27 '18 at 1:24














0












0








0








$aak is show 00:17:00 and i just want get 17



$aak=$data2["jamwaktukerja"];


i use this code for get minute,but still wrong



$time = date("i ", $aak);

var_dump($time);


$masuk2 = 'UPDATE presensi SET menitwaktukerja ="'.$time.'" where
tanggal="'.$cellValueB.'" and nip="'.$data1["nip"].'" ';
$query4 = mysqli_query($con,$masuk2);









share|improve this question
















$aak is show 00:17:00 and i just want get 17



$aak=$data2["jamwaktukerja"];


i use this code for get minute,but still wrong



$time = date("i ", $aak);

var_dump($time);


$masuk2 = 'UPDATE presensi SET menitwaktukerja ="'.$time.'" where
tanggal="'.$cellValueB.'" and nip="'.$data1["nip"].'" ';
$query4 = mysqli_query($con,$masuk2);






php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 1:20









Jeff

6,58311027




6,58311027










asked Nov 27 '18 at 1:17









kagamikagami

257




257













  • you need to provide date with a valid timestamp as second parameter. 00:17:00 is not a timestamp yet.You can use strtotime() for that.

    – Jeff
    Nov 27 '18 at 1:22








  • 1





    If you are 100% sure, that the input is always in this format you could $time = explode(':', $aak) and you'll have the minutes in $time[1].

    – Jeff
    Nov 27 '18 at 1:24



















  • you need to provide date with a valid timestamp as second parameter. 00:17:00 is not a timestamp yet.You can use strtotime() for that.

    – Jeff
    Nov 27 '18 at 1:22








  • 1





    If you are 100% sure, that the input is always in this format you could $time = explode(':', $aak) and you'll have the minutes in $time[1].

    – Jeff
    Nov 27 '18 at 1:24

















you need to provide date with a valid timestamp as second parameter. 00:17:00 is not a timestamp yet.You can use strtotime() for that.

– Jeff
Nov 27 '18 at 1:22







you need to provide date with a valid timestamp as second parameter. 00:17:00 is not a timestamp yet.You can use strtotime() for that.

– Jeff
Nov 27 '18 at 1:22






1




1





If you are 100% sure, that the input is always in this format you could $time = explode(':', $aak) and you'll have the minutes in $time[1].

– Jeff
Nov 27 '18 at 1:24





If you are 100% sure, that the input is always in this format you could $time = explode(':', $aak) and you'll have the minutes in $time[1].

– Jeff
Nov 27 '18 at 1:24












1 Answer
1






active

oldest

votes


















2














There are several ways to get the minutes of that input string.



Using explode - use only if the input is always the same format:



<?php

$aak = "00:17:00";

$time = explode(':', $aak);
$minutes = $time[1];

echo $minutes; // 17


Using DateTime Class:



$aak = "00:17:00";
// either with specified format:
$d = DateTime::createFromFormat("H:i:s",$aak);
// or without:
$d = new DateTime($aak);
$minutes = $d->format("i");
echo $minutes; // 17

// as a oneliner:

$minutes = (new DateTime($aak))->format("i");


Go the way you did, via date(), but provide it with a valid timestamp created with strtotime():



$aak = "00:17:00";
$timestamp = strtotime($aak);
$minutes = date("i", $timestamp);
echo $minutes; // 17





share|improve this answer


























  • thank it's work

    – kagami
    Nov 27 '18 at 2:06












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491438%2ftake-minutes-only-from-the-time-format-in-php-before-the-record-update%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














There are several ways to get the minutes of that input string.



Using explode - use only if the input is always the same format:



<?php

$aak = "00:17:00";

$time = explode(':', $aak);
$minutes = $time[1];

echo $minutes; // 17


Using DateTime Class:



$aak = "00:17:00";
// either with specified format:
$d = DateTime::createFromFormat("H:i:s",$aak);
// or without:
$d = new DateTime($aak);
$minutes = $d->format("i");
echo $minutes; // 17

// as a oneliner:

$minutes = (new DateTime($aak))->format("i");


Go the way you did, via date(), but provide it with a valid timestamp created with strtotime():



$aak = "00:17:00";
$timestamp = strtotime($aak);
$minutes = date("i", $timestamp);
echo $minutes; // 17





share|improve this answer


























  • thank it's work

    – kagami
    Nov 27 '18 at 2:06
















2














There are several ways to get the minutes of that input string.



Using explode - use only if the input is always the same format:



<?php

$aak = "00:17:00";

$time = explode(':', $aak);
$minutes = $time[1];

echo $minutes; // 17


Using DateTime Class:



$aak = "00:17:00";
// either with specified format:
$d = DateTime::createFromFormat("H:i:s",$aak);
// or without:
$d = new DateTime($aak);
$minutes = $d->format("i");
echo $minutes; // 17

// as a oneliner:

$minutes = (new DateTime($aak))->format("i");


Go the way you did, via date(), but provide it with a valid timestamp created with strtotime():



$aak = "00:17:00";
$timestamp = strtotime($aak);
$minutes = date("i", $timestamp);
echo $minutes; // 17





share|improve this answer


























  • thank it's work

    – kagami
    Nov 27 '18 at 2:06














2












2








2







There are several ways to get the minutes of that input string.



Using explode - use only if the input is always the same format:



<?php

$aak = "00:17:00";

$time = explode(':', $aak);
$minutes = $time[1];

echo $minutes; // 17


Using DateTime Class:



$aak = "00:17:00";
// either with specified format:
$d = DateTime::createFromFormat("H:i:s",$aak);
// or without:
$d = new DateTime($aak);
$minutes = $d->format("i");
echo $minutes; // 17

// as a oneliner:

$minutes = (new DateTime($aak))->format("i");


Go the way you did, via date(), but provide it with a valid timestamp created with strtotime():



$aak = "00:17:00";
$timestamp = strtotime($aak);
$minutes = date("i", $timestamp);
echo $minutes; // 17





share|improve this answer















There are several ways to get the minutes of that input string.



Using explode - use only if the input is always the same format:



<?php

$aak = "00:17:00";

$time = explode(':', $aak);
$minutes = $time[1];

echo $minutes; // 17


Using DateTime Class:



$aak = "00:17:00";
// either with specified format:
$d = DateTime::createFromFormat("H:i:s",$aak);
// or without:
$d = new DateTime($aak);
$minutes = $d->format("i");
echo $minutes; // 17

// as a oneliner:

$minutes = (new DateTime($aak))->format("i");


Go the way you did, via date(), but provide it with a valid timestamp created with strtotime():



$aak = "00:17:00";
$timestamp = strtotime($aak);
$minutes = date("i", $timestamp);
echo $minutes; // 17






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 27 '18 at 10:22

























answered Nov 27 '18 at 1:27









JeffJeff

6,58311027




6,58311027













  • thank it's work

    – kagami
    Nov 27 '18 at 2:06



















  • thank it's work

    – kagami
    Nov 27 '18 at 2:06

















thank it's work

– kagami
Nov 27 '18 at 2:06





thank it's work

– kagami
Nov 27 '18 at 2:06




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491438%2ftake-minutes-only-from-the-time-format-in-php-before-the-record-update%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen