#!/usr/bin/perl
@x=(0x50,-82,0xd,-3,-12,0x5,0x1,0xd,0x41,-84,0x1,
-2,0x2b,0x4a);$Z=sub{for($z=@_;$z;$z--){unshift(
@z,chr($_[$z]+$z{z}));$z{z}+=$_[$z];}while($z=pop
(@z)){print($z);}};$z=$Z;@Z=(0xd,-6,0x8,0x2);$Z->
((0,0,0,-68,@Z,-7,0x48,-76,-6,0xd,-11,@x));
mark got me thinking about this, and then i was messing around with one of my own projects that needed the same feature, and i realized the easy way to do it.
i would always get the year/month/day out of a timestamp using the date() function, and then create a new timestamp with mktime().
i just realized the best way is:
$now = time();
$beginning_of_day = $now - ($now % 86400);
this works for me because i definitely remember that number for seconds in a day, and avoids any locale-dependent variations. plus, end of day becomes just as easy.