Skip to content

Instantly share code, notes, and snippets.

<?php
$atret = date("d-m-Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'." -3 day"))));
echo $atret;
?>
@boy3vil
boy3vil / PHP calculating date distance
Last active December 16, 2025 17:06
kalkulasi tanggal pada PHP
<?php
$date1 = "2014-06-29";
$date2 = "2014-07-02";
$diff = abs(strtotime($date2) - strtotime($date1));
$days = floor($diff /(60*60*24));
echo $days;
@boy3vil
boy3vil / DISTINCT date from date time sql
Created July 5, 2014 16:45
DISTINCT date from date time sql
SELECT DISTINCT DATE_FORMAT(`field_tgl`, '%Y-%m-%d') as tgl FROM table ORDER BY tgl
tgl
----------
2014-06-01
2014-06-02
2014-06-06
2014-06-10
2014-06-20
@boy3vil
boy3vil / where clause date from datetime
Created July 6, 2014 04:47
where clause date from datetime
SELECT * FROM `table` WHERE CAST(`field_TANGGAL` AS DATE) = '2014-06-01'
@boy3vil
boy3vil / sql group duplicate value
Created September 10, 2014 14:11
sql group duplicate value
SELECT col,
COUNT(dupe_col) AS dupe_cnt
FROM TABLE
GROUP BY col
HAVING COUNT(dupe_col) > 1
ORDER BY COUNT(dupe_col) DESC
1
1
@boy3vil
boy3vil / sql get field names from table specific database
Created September 12, 2014 03:38
sql get field names from table specific database
SELECT DISTINCT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'column_name'
AND TABLE_SCHEMA='database_name'
COLUMN_NAME
-------------
id
@boy3vil
boy3vil / stored prosedure sql php
Created October 8, 2014 10:11
stored prosedure sql php
#---------- create table -------------
CREATE TABLE contoh
(
`no` int(2),
`nama` varchar(255)
);
#---------- end create table -------------
#---------- insert table -------------
@boy3vil
boy3vil / $.extend jquery function
Created October 19, 2014 08:52
contoh sederhana menggunakan jQuery $.extend pada function
<p>test</p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function(){
$('p').click(function(){
$(this).cek({
warna : "red",
ukuran: 15
});
@boy3vil
boy3vil / C# json parse
Last active August 29, 2015 14:09
json string to object
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json.Linq;
@boy3vil
boy3vil / C PROGRAM FILE & COMMAND LINE MULTI ARGUMENT
Created December 27, 2014 14:30
C PROGRAM FILE & COMMAND LINE MULTI ARGUMENT
// gcc -Wall -o hasil program.c
// hasil -l nama_file
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (int argc, char *argv[]){
// memastikan metode pengimputan terdiri dari 3 bagian